-
Notifications
You must be signed in to change notification settings - Fork 919
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch Bedrock to using Django's own i18n mechanism #14327
Commits on Apr 17, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 590bb46 - Browse repository at this point
Copy the full SHA 590bb46View commit details -
[Breaking] Allow mixed-case lang codes as settings.LANGUAGES and rela…
…ted lang-code lookups
Configuration menu - View commit details
-
Copy full SHA for 1c2d4f5 - Browse repository at this point
Copy the full SHA 1c2d4f5View commit details -
[Breaking] Use i18n_patterns to lang-code prefix relevant paths in mo…
…zorg.urls This includes splitting mozorg.urls into two groups so we only use i18n_patterns with paths that need it. We've kept the main, localed, group's name to be urls.py to reduce the chance of merge conflicts, as this piece of work is likely to need rebasing against main quite a lot until it's ready. The decision about which get prefixed and which do not is based on the settings SUPPORTED_NONLOCALES and SUPPORTED_LOCALE_IGNORE that were used in our former i18n machinery. At the time of committing, they still exist, but both of should be able to be removed once this work is done (or at least moved to power some tests)
Configuration menu - View commit details
-
Copy full SHA for b768cb3 - Browse repository at this point
Copy the full SHA b768cb3View commit details -
[Breaking] We now have /en-US/ resolving/rendering for the homepage, …
…but not yet /fr/ We use a prefixer for our i18n_urlpatterns so that when we reverse() and resolve() we allow for a custom prefix that is normalized to our mixed-case lang codes. Tests are needed.
Configuration menu - View commit details
-
Copy full SHA for 34289ba - Browse repository at this point
Copy the full SHA 34289baView commit details -
Add middleware to fix up the lang code in the path
This essentially replaces urlresolves.Prefixer.fix() Tests are needed.
Configuration menu - View commit details
-
Copy full SHA for 5b8eda3 - Browse repository at this point
Copy the full SHA 5b8eda3View commit details -
Configuration menu - View commit details
-
Copy full SHA for 4438da2 - Browse repository at this point
Copy the full SHA 4438da2View commit details -
Configuration menu - View commit details
-
Copy full SHA for 404fa05 - Browse repository at this point
Copy the full SHA 404fa05View commit details -
Ensure the request is annotated with the relevant lang_code, so that …
…it's available in templates
Configuration menu - View commit details
-
Copy full SHA for bf3985a - Browse repository at this point
Copy the full SHA bf3985aView commit details -
Configuration menu - View commit details
-
Copy full SHA for e79df9c - Browse repository at this point
Copy the full SHA e79df9cView commit details -
Configuration menu - View commit details
-
Copy full SHA for 1e33859 - Browse repository at this point
Copy the full SHA 1e33859View commit details -
Configuration menu - View commit details
-
Copy full SHA for 837df57 - Browse repository at this point
Copy the full SHA 837df57View commit details -
Configuration menu - View commit details
-
Copy full SHA for 3fd9d94 - Browse repository at this point
Copy the full SHA 3fd9d94View commit details -
Configuration menu - View commit details
-
Copy full SHA for 0ed076d - Browse repository at this point
Copy the full SHA 0ed076dView commit details -
Update tests for accepted locales
Note that we no longer have a lowercase-to-mixed-case lang lookup, so this test changes but might become redundant later in the refactor
Configuration menu - View commit details
-
Copy full SHA for d50def3 - Browse repository at this point
Copy the full SHA d50def3View commit details -
Configuration menu - View commit details
-
Copy full SHA for de5b8ae - Browse repository at this point
Copy the full SHA de5b8aeView commit details -
Configuration menu - View commit details
-
Copy full SHA for 2a24e7d - Browse repository at this point
Copy the full SHA 2a24e7dView commit details -
Extend Django's support for get_language_info to include our three-ch…
…aracter lang names, which it doesn't have by default This is a part of ensuring three-letter country codes still work, but it might be redundant - TBC
Configuration menu - View commit details
-
Copy full SHA for 07803dd - Browse repository at this point
Copy the full SHA 07803ddView commit details -
Configuration menu - View commit details
-
Copy full SHA for c7d7b7f - Browse repository at this point
Copy the full SHA c7d7b7fView commit details -
Drop unnecessary work in custom locale middleware
This was useful before we started using i18n_patterns, but now not all of it is needed. Some still is, though
Configuration menu - View commit details
-
Copy full SHA for 07952b0 - Browse repository at this point
Copy the full SHA 07952b0View commit details -
Fixup redirects behaviour (using /webvision/ as an example case)
* Redirects don't need url prefixing via i18n_patterns, so we're moving them to nonlocale_urls instead. * When detecting a language, en-CA was being picked over en-US, which is avoided by ensuring en-US is at the start of the languages list * Note that for the webvision redirect we needed to add: * locale_prefix=True * prepend_locale=False
Configuration menu - View commit details
-
Copy full SHA for c541093 - Browse repository at this point
Copy the full SHA c541093View commit details -
Amend VPNRC tests - tweaking where appropriate; also dropped a fiddly…
… and unrealistic test
Configuration menu - View commit details
-
Copy full SHA for 59fe9a7 - Browse repository at this point
Copy the full SHA 59fe9a7View commit details -
Configuration menu - View commit details
-
Copy full SHA for 919fd6f - Browse repository at this point
Copy the full SHA 919fd6fView commit details -
Fix need for fallback to settings.LANGUAGE_CODE if no language can be…
… detected/retrieved
Configuration menu - View commit details
-
Copy full SHA for 5fdde80 - Browse repository at this point
Copy the full SHA 5fdde80View commit details -
Reinstate logic to handle fallback to appropriate locale based on Acc…
…ept-Language header
Configuration menu - View commit details
-
Copy full SHA for f9e93df - Browse repository at this point
Copy the full SHA f9e93dfView commit details -
Move mozorg redirect() calls to redirects.py to avoid the routes havi…
…ng lang codes prefixed to them
Configuration menu - View commit details
-
Copy full SHA for 62dfd25 - Browse repository at this point
Copy the full SHA 62dfd25View commit details -
Configuration menu - View commit details
-
Copy full SHA for 74d3617 - Browse repository at this point
Copy the full SHA 74d3617View commit details -
Configuration menu - View commit details
-
Copy full SHA for 4fcc522 - Browse repository at this point
Copy the full SHA 4fcc522View commit details -
Configuration menu - View commit details
-
Copy full SHA for 201a98f - Browse repository at this point
Copy the full SHA 201a98fView commit details -
Configuration menu - View commit details
-
Copy full SHA for e972c9c - Browse repository at this point
Copy the full SHA e972c9cView commit details -
Configuration menu - View commit details
-
Copy full SHA for 8736ecc - Browse repository at this point
Copy the full SHA 8736eccView commit details -
Configuration menu - View commit details
-
Copy full SHA for 02f17e6 - Browse repository at this point
Copy the full SHA 02f17e6View commit details -
Configuration menu - View commit details
-
Copy full SHA for 5765ec8 - Browse repository at this point
Copy the full SHA 5765ec8View commit details -
Move redirects out of urls.py so that they remain language agnostic -…
… tweak _one_ test related to this
Configuration menu - View commit details
-
Copy full SHA for c3c4ed0 - Browse repository at this point
Copy the full SHA c3c4ed0View commit details -
Avoid unnecessarily adding lang code to a reversed() url in our redir…
…ector - we don't need it unless we explicitly ask for it
Configuration menu - View commit details
-
Copy full SHA for 3baf110 - Browse repository at this point
Copy the full SHA 3baf110View commit details -
Configuration menu - View commit details
-
Copy full SHA for 8f19837 - Browse repository at this point
Copy the full SHA 8f19837View commit details -
Configuration menu - View commit details
-
Copy full SHA for e7773e6 - Browse repository at this point
Copy the full SHA e7773e6View commit details -
Fixing tests with settings=DEV
* Contentful-related tests needed the dev-urls config wrapping in URLpatterns to make it work as per the real site; if we just specced dev_urls they did not work because they were not i18n-patterned
Configuration menu - View commit details
-
Copy full SHA for 8b3771d - Browse repository at this point
Copy the full SHA 8b3771dView commit details -
Default a locale to '' not None - the latter causes Locale page to bl…
…ow up and the former matches original behaviour better
Configuration menu - View commit details
-
Copy full SHA for 3be47ce - Browse repository at this point
Copy the full SHA 3be47ceView commit details -
Configuration menu - View commit details
-
Copy full SHA for e26dc61 - Browse repository at this point
Copy the full SHA e26dc61View commit details -
Configuration menu - View commit details
-
Copy full SHA for fa03b0b - Browse repository at this point
Copy the full SHA fa03b0bView commit details -
Configuration menu - View commit details
-
Copy full SHA for f057e62 - Browse repository at this point
Copy the full SHA f057e62View commit details -
Monkeypatch Django's check_for_language() because it looks in the wro…
…ng place for us By default check_for_language() seeks gettext-compatible files in locale/ directories in the project, but we don't have those because our l10n is handled using Fluent strings in the www-l10n-team directory, cloned from their git repo. So, instead, we just perform a light check to see whether a given lang is among the langs that shold be available. The actual decision about whether we have have (enough) Fluent strings available for that locale happens in lib.l10n_utils.render()
Configuration menu - View commit details
-
Copy full SHA for 5c2b4b5 - Browse repository at this point
Copy the full SHA 5c2b4b5View commit details -
Configuration menu - View commit details
-
Copy full SHA for 0fe343d - Browse repository at this point
Copy the full SHA 0fe343dView commit details -
Configuration menu - View commit details
-
Copy full SHA for 429a9fa - Browse repository at this point
Copy the full SHA 429a9faView commit details -
Add tests for language-code fixup + slight refactor to ensure it does…
…n't to _too_ much
Configuration menu - View commit details
-
Copy full SHA for 609eae3 - Browse repository at this point
Copy the full SHA 609eae3View commit details -
Configuration menu - View commit details
-
Copy full SHA for 1c2f119 - Browse repository at this point
Copy the full SHA 1c2f119View commit details -
Drop unnecessary-after-all patching of LANG_INFO - we found a differe…
…nt route to making check_for_language work; this was the wrong direction
Configuration menu - View commit details
-
Copy full SHA for 646bfbf - Browse repository at this point
Copy the full SHA 646bfbfView commit details -
Configuration menu - View commit details
-
Copy full SHA for 8ea97e3 - Browse repository at this point
Copy the full SHA 8ea97e3View commit details -
Configuration menu - View commit details
-
Copy full SHA for 85c2694 - Browse repository at this point
Copy the full SHA 85c2694View commit details -
Support special-case showing of a locale list at / if no accept-lang …
…header is present This changeset ensures we retain the existing behaviour where a robot/spider going to / with no accept-language header gets a 200 OK response but with a locale-picker page, NOT the homepage. The fix here was to avoid running Django's LocaleMiddleware when (and only when) we detect the special case of a request for the root path and no Accept-Language header - which is basically a call for the root page with no way to determine the client's locale. (We don't use sessions in Bedrock so Django will never find a language code in a session anyway)
Configuration menu - View commit details
-
Copy full SHA for 3aef3c3 - Browse repository at this point
Copy the full SHA 3aef3c3View commit details -
Improve naming to avoid confusion between polish (verb) and Polish in…
… split_path_and_polish_lang
Configuration menu - View commit details
-
Copy full SHA for 53f94e2 - Browse repository at this point
Copy the full SHA 53f94e2View commit details -
Configuration menu - View commit details
-
Copy full SHA for 19b5aad - Browse repository at this point
Copy the full SHA 19b5aadView commit details -
Configuration menu - View commit details
-
Copy full SHA for f968cb9 - Browse repository at this point
Copy the full SHA f968cb9View commit details