fyne
fyne copied to clipboard
FEATURE: Setting preferred locale and fallback manually
Description:
Sometimes you might want the user to load a different language file, other than the systems current locale.
This adds a SetPreferredLocale()
that you can call before or after for example AddTranslationsFS()
and will set a custom locale.
This way, the preferred language is looked up for translations.
Also added a SetLanguageOrder()
function that reorders the added languages, in which case the first language is used as fallback when no locale is found.
with this, on a foreign language OS system, you can call
lang.AddTranslationsFS(Resources.Translations, "translations")
lang.SetLanguageOrder([]string{"fr"}) // sets fr as fallback language
lang.SetPreferredLocale("en-US") // use english instead of system locale
Checklist:
- [ ] Tests included.
- [ ] Lint and formatter run with no errors.
- [ ] Tests all pass.
Where applicable:
- [ ] Public APIs match existing style and have Since: line.
- [ ] Any breaking changes have a deprecation path or have been discussed.
- [ ] Check for binary size increases when importing new modules.