Open Rapougnac opened 1 month ago
TLDR:
The developer must define fallbacks to every language code similarly to base_locale
.
For example,
base_locale: en-GB
base_locales:
de: 'de-DE'
fr: 'fr-FR'
en: 'en-GB'
Logically, if there is only de-AT
, de-LI
, and de-CH
while there is a string in de-AT
is missing, what should be chosen? de-LI
or de-CH
? A more relevant issue arises with Chinese languages: zh-CN
, zh-HK
, zh-TW
, here we don't have a clear order if one of them is missing.
Technially, it is important to find the precedence order because we only have 2 viable options:
(1) Fallback during runtime
Similarly to the current fallback mechanism, we need to introduce another inheritance step: DeCh
extends DeDe
extends enGb
. What should be the order? It must be defined.
(2) Fallback during code generation
We could render the fallback strings during code generation but since slang currently generates each locale one by one, we need an explicit order: en-GB
, then de-DE
, then de-CH
. If de-CH
is generated before de-DE
, there would be no fallback since there is no other de
generated yet.
Is there a way to fallback to the language code?
For example, say I have
en-GB
,de-DE
andde-CH
. Mybase_locale
is set asen-GB
. What I'd like to have, is for example.en-GB
:de-DE
:de-CH
:In this example, the
hello
would return the value set, butcat
should returnKatze
for bothde-DE
andde-CH
locales. And if thefallback
is not set, this would fall again toen-GB
.I hope that was clear :)