-
-
Notifications
You must be signed in to change notification settings - Fork 32
Open
Description
Description
Let's say your app supports english and german language. User with czech locale logs in and the app fallbacks to english.
Currently, if you setup i18n like this:
export const i18n = new I18n(
enableHiddenFeatures
? translations
: {
en: translations.en,
de: translations.de,
}
)
i18n.locale = 'cs'
i18n.defaultLocale = 'en'
i18n.enableFallback = truei18n.locale returns "cs" despite en translations being used.
Describe the solution
Add function getUsedLocale() that will return locale that is currently used by the library.
Alternatives you considered
In my example above, we can test keys(translations).include(I18n.locale), but parsing language code is not that straight forward usually it might be in format like da_DK or de_DE. This logic is already included in the library and it does not seem right to duplicate it to find out what language is used.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels