Skip to content

Commit

Permalink
Merge pull request #894 from endlessm/893-loading-screen-tx-loading
Browse files Browse the repository at this point in the history
Improve loading screen translation loading
  • Loading branch information
manuq authored Oct 23, 2023
2 parents b2c4cf5 + db6ceb8 commit 1013eb6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion packages/loading-screen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"build": "yarn run compile-messages && vue-cli-service build --no-module && yarn zip",
"lint": "vue-cli-service lint",
"zip": "../../scripts/bundle_zip.py loading-screen.zip",
"extract-messages": "formatjs extract 'src/**/*.{js,vue}' --format transifex --out-file lang/en-US.json",
"extract-messages": "formatjs extract 'src/**/*.{js,vue}' --format transifex --out-file lang/en.json",
"compile-messages": "formatjs compile-folder --format transifex lang compiled-lang"
},
"dependencies": {
Expand Down
13 changes: 11 additions & 2 deletions packages/loading-screen/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import LoadingRetry from '@/views/LoadingRetry.vue';
import store from "@/store";

// Language codes are RFC 5646 (https://datatracker.ietf.org/doc/html/rfc5646)
const supportedLocales = ['en-US', 'es-419'];
const defaultLocale = 'en-US';
const supportedLocales = ['en', 'es'];
const defaultLocale = 'en';
const requestedLocales = navigator.languages;

function loadLocaleData(locale) {
Expand All @@ -32,6 +32,15 @@ async function loadBestLocaleData(locales) {
}
}

// Try again with only the locale's language.
for (const lang of locales.map(l => l.split('-')[0].toLowerCase())) {
try {
return await loadLocaleData(lang);
} catch {
continue;
}
}

return await loadLocaleData(defaultLocale);
}

Expand Down

0 comments on commit 1013eb6

Please sign in to comment.