Skip to content
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

Fallback to the language code? #219

Open
Rapougnac opened this issue May 6, 2024 · 1 comment
Open

Fallback to the language code? #219

Rapougnac opened this issue May 6, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@Rapougnac
Copy link

Rapougnac commented May 6, 2024

Is there a way to fallback to the language code?

For example, say I have en-GB, de-DE and de-CH.
My base_locale is set as en-GB.
What I'd like to have, is for example.
en-GB:

hello: Hello
cat: cat
fallback: I'm still standing

de-DE:

hello: Hallo
cat: Katze

de-CH:

hello: Grüezi

In this example, the hello would return the value set, but cat should return Katze for both de-DE and de-CH locales.
And if the fallback is not set, this would fall again to en-GB.

I hope that was clear :)

@Tienisto Tienisto added the enhancement New feature or request label May 9, 2024
@Tienisto
Copy link
Member

Tienisto commented May 9, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants