Repository navigation
Conversation
A new site role reads i18n_languages from the configuration and, for each request, picks the language from ?lang=, the lang cookie or the Accept-Language header. It switches gettext (Locale::TextDomain, text domain sgn) to that language and back to English after the request. Without i18n_languages nothing changes. AI-Tool: Claude Code
Accept-Language entries with q=0 mean "not this language"; they were
still chosen when nothing else matched ("uk;q=0, de" gave Ukrainian).
They are now dropped before the language is detected.
The language went back to English in "after finalize", which does not run
when finalize dies. The reset now wraps handle_request with Try::Tiny's
finally, so every request ends in English whatever happens in it.
AI-Tool: Claude Code
The role loaded Locale::Messages at compile time, so SGN did not start without libintl-perl even when i18n_languages was unset. It now loads it in setup_finalize, only when languages are configured, and stops the start with a clear message when the library is missing. The role test skips without the library; a new test hides it and checks both cases. AI-Tool: Claude Code
Without i18n_languages the role did not set the text domain's codeset and UTF-8 filter, so gettext gave the English text back as bytes. A wrapped text with a non-ASCII letter (a no-break space, for example) was then escaped byte by byte: "( " became "(Â " on the page. When libintl-perl is installed, the filter is now set in every mode. AI-Tool: Claude Code
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
First step towards an interface in the visitor's language. Nothing changes unless
i18n_languagesis set in the config: every request stays English, andlibintl-perlis not needed.SGN::Role::Site::I18N. For each request it takes the language from?lang=, thelangcookie or theAccept-Languageheader (languages withq=0are skipped), switches gettext (text domainsgn) to it, and goes back to English at the end of the request, also when the request dies.libintl-perlis installed, gettext returns Perl characters in every mode, English included, so a translated text with a non-ASCII letter is escaped once on the page.libintl-perl(Locale::Messages) is loaded only wheni18n_languagesis set. A wrong setup (the library, a catalog or a system locale missing for a listed language) stops the server at start, with a message that names the problem.Build.PLlistsLocale::TextDomain. Lint checks the whole changed file, so I addeduse strict; use warnings;there.About solgenomics/breedbase_dockerfile#63. This PR runs on the current image without
libintl-perl. The next PRs of the chain (texts in Mason templates) need the library in the image, so they wait for #63.Tests in
breedbase/breedbase:latest: withoutlibintl-perlthe wholeprove --recurse t/unitpasses (38 files, 1594 tests;I18N.tis skipped,I18N_off.tchecks that the site starts and that a configured language stops the start with a clear message). Withlibintl-perlinstalled it passes too (1601 tests); the checks forq=0and for a request that dies fail on the first commit.Next in the chain: Mason components that can translate text.
Part of #5915.
Checklist