Opened 8 years ago
Last modified 8 years ago
#28636 new New feature
Translation module: Check `LANG_INFO` against user's language preference as optional feature — at Version 2
| Reported by: | Denis Anuschewski | Owned by: | nobody |
|---|---|---|---|
| Component: | Internationalization | Version: | dev |
| Severity: | Normal | Keywords: | translation, internationalization, request |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | yes | Needs documentation: | yes |
| Needs tests: | yes | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Problem: In the current state, the user's discovered language preference is only returned when found in settings.LANGUAGES. That's more than sufficient for the normal translation routine, but there seems to be no way (at least no DRY way) to find out a user's preference REGARDLESS of settings.LANGUAGES.
Suggestion: It would be nice to have an easy way for finding out a languange preference from request, even if it's not listed in your supported languages. You could think of an optional flag, so that the preference from get_language_from_request is checked against LANG_INFO in the translation module rather than against settings.LANGUAGES. This would give you one of all available languages in the translation module. You could use that e.g. for comparing with settings.LANGUAGE_CODE and add a fallback for specific cases.
Change History (2)
comment:2 by , 8 years ago
| Component: | Utilities → Internationalization |
|---|---|
| Description: | modified (diff) |
| Keywords: | internationalization added; locale removed |
In my specific case I wrote a sub class from
LocaleMiddlewarein order to useadd_fallbackwhenever a language gets detected that is not equal tosettings.LANGUAGE_CODE. But that seems to be not possible with current Django because you always get the value ofsettings.LANGUAGE_CODEwhen the discovered language is not insettings.LANGUAGES.Overwriting the function
get_languagesdidn't work for me because translation was then activated for every language. I would like to have translations only for specific languages when I explicitly put them intosettings.LANGUAGES, but also a fallback for every language except ofsettings.LANGUAGE_CODE.