mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-22 15:55:33 +03:00
Fix locale fallback
This commit is contained in:
parent
e8544110f8
commit
fbfb523b4d
1 changed files with 21 additions and 0 deletions
|
@ -123,6 +123,27 @@ function getValidLocale(userLocale) {
|
|||
|
||||
if (userLocale == 'DEFAULT') {
|
||||
userLocale = window.navigator.userLanguage || window.navigator.language;
|
||||
console.log('Detected locale ' + userLocale);
|
||||
|
||||
// The i18next can fallback automatically to the dialect, but needs to be used with hyphen and
|
||||
// we use underscore because the eventPage.js uses Chrome localization that needs underscore.
|
||||
// If at some moment we get rid of the Chrome localization we can remove all of this
|
||||
userLocale = userLocale.replace('-','_');
|
||||
// Locale not found
|
||||
if (languagesAvailables.indexOf(userLocale) == -1) {
|
||||
// Is a composite locale?
|
||||
var underscorePosition = userLocale.indexOf('_');
|
||||
if (underscorePosition != -1) {
|
||||
userLocale = userLocale.substring(0, underscorePosition);
|
||||
// Locale dialect fallback not found
|
||||
if (languagesAvailables.indexOf(userLocale) == -1) {
|
||||
userLocale = 'en'; // Fallback language
|
||||
}
|
||||
} else {
|
||||
userLocale = 'en';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return userLocale;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue