i18n.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.
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:
i18n.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 likeda_DK
orde_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.