Fix language auto-detection

This commit is contained in:
Denis Perov 2022-04-21 19:41:56 +03:00
parent 566527dfad
commit 8f43b74bbc
3 changed files with 17 additions and 3 deletions

View file

@ -16,6 +16,15 @@ Meteor.startup(() => {
navigator.userLanguage,
].filter(Boolean);
if (language) {
TAPi18n.setLanguage(language);
// Try with potentially complex language tag
if (TAPi18n.isLanguageSupported(language)) {
TAPi18n.setLanguage(language);
} else if (language.includes('-')) {
// Fallback to a general language
const [general] = language.split('-');
if (TAPi18n.isLanguageSupported(general)) {
TAPi18n.setLanguage(general);
}
}
}
});