-
Notifications
You must be signed in to change notification settings - Fork 110
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
Remove Django's LocaleMiddleware from the app #5701
Conversation
Because we always activate Spanish-language content via the inclusion of an `/es/` path segment that triggers the setting of the `language` context variable to `es`, we do not need this middleware for anything currently, and its presence can cause unwanted appearance of Spanish on English pages if a user has set their browser's primary language to Spanish.
This is not true. We have 63 Spanish blog pages that do not use an /es/ path segment, such as /about-us/blog/errores-comunes-que-la-gente-encuentra-en-su-reporte-de-credito-y-como-corregirlos/ What drives translations for those and other Wagtail pages is the But I would lean toward honoring the preferences of those probably rare users who go to the trouble of setting their browsers' default language. If they want to see every translatable thing available, why not let them? We do have an odd (and also rare) caching problem that this might solve, but for me that doesn't tip the scale. |
Thanks for pointing that out, Bill; I didn't remember that.
Because the way that our caching system currently works, their browser language preference is already ignored, and Akamai returns the English page anyway. (Assuming that an English-language user was the first to visit the page after the cache was invalidated.) We may want to investigate whether or not Akamai can return alternate versions of the page based on browser language settings. |
Not entirely, at least not in my testing. I just hit https://www.consumerfinance.gov/data-research/consumer-complaints/ in Chrome with my default language set to Spanish, and I got Spanish header and footer elements, including the search bar ("Buscar"), which could help a Spanish-only-speaker find something. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we always activate Spanish-language content via the inclusion of
an /es/ path segmentThis is not true. We have 63 Spanish blog pages that do not use an /es/ path segment, such as
There are several other non-blog Spanish pages elsewhere in the tree, both Wagtail (ex: https://www.consumerfinance.gov/consumer-tools/sending-money/es/) and non-Wagtail (ex: https://www.consumerfinance.gov/consumer-tools/retirement/before-you-claim/es/).
These both have |
Well, that's surprising and confusing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thing this seems to give us is consistency between our Django and Jinja templates. The question of whether this is the correct approach to translation is... still very much open, but seems way above our paygrades.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I bow to simplicity.
Because we always activate Spanish-language content via the inclusion of
an
/es/
path segment that triggers the setting of thelanguage
context variable to
es
, we do not need this middleware for anythingcurrently, and its presence can cause unwanted appearance of Spanish on
English pages if a user has set their browser's primary language to
Spanish.
Removals
django.middleware.locale.LocaleMiddleware
removed fromMIDDLEWARE
in our base settings fileTesting
/data-research/consumer-complaints/
using your favorite way to bypass Akamai, observe some parts of the global header and footer appearing in SpanishChecklist
Testing checklist
Browsers