Rethink i18n + l10n #1338
Labels
annoying
discussion
These topics must be discussed before completion
Priority: Medium
This issue may be useful, and needs some attention.
usability
We have this
current.language
property together with ani18n
module and some more containers, but their implementation lacks a consistent and well thought-out concept. As always with ViUR, unfortunately.Here is an overview of the components that make use of it:
Router._select_language
Cache
i18n.LanguageWrapper
i18n.translate
StringBone.buildDBFilter
fallbackHtmlRender.getTemplateFileName
ViRender.setLanguage
available_languages
are valid)utils.seoUrlToEntry
utils.seoUrlToFunction
getLanguage
Module.seo_language_map
(SEO alias of module)available_languages
are used)As you can see, it is purely arbitrary whether a method always resolves the aliases to the language, selects the alias first and only selects the language as a fallback or only uses the main languages.
This means that the
current.language
constantly changes its meaning between language and alias. How are you supposed to generate consistent output with this?But what is exactly the purpose of this alias? Is it supposed to represent a region, as you would do with locales?
But that doesn't work as soon as a region has several languages.
For example, Belgium has three official languages: Dutch, French, and German. Or Canada: French and English.
If this alias map is a dict str -> str, it cannot be mapped. The keys would overwrite each other.
How could we solve this in the future?
Instead of a language, we use a locales.
Consisting of the ISO 639 two-letter language code e.g.
de
, andDE
as ISO 3166 two-letter country code. Resulting in:de-DE
.Then it must be possible in any bones, translations, etc. to store both:
fr
),fr-BE
).If the user has now stored the locale
fr-BE
in his session, the method first tries to load the value forfr-BE
, if this does not exist (or is empty), it falls back to the language "fr". In the worst case, of course, to a fallback language.The text was updated successfully, but these errors were encountered: