mirror of
https://github.com/schlagmichdoch/PairDrop.git
synced 2025-04-23 16:26:17 -04:00
Load initial translation as proper async call instead of using an event
This commit is contained in:
parent
021c67bd77
commit
5a2ec9c670
2 changed files with 22 additions and 22 deletions
|
@ -14,13 +14,6 @@ class Localization {
|
|||
Localization.initialLocale = storedLanguageCode && Localization.isSupported(storedLanguageCode)
|
||||
? storedLanguageCode
|
||||
: Localization.systemLocale;
|
||||
|
||||
Localization
|
||||
.setTranslation(Localization.initialLocale)
|
||||
.then(_ => {
|
||||
console.log("Initial translation successful.");
|
||||
Events.fire("initial-translation-loaded");
|
||||
});
|
||||
}
|
||||
|
||||
static isSupported(locale) {
|
||||
|
@ -41,6 +34,10 @@ class Localization {
|
|||
|| Localization.defaultLocale;
|
||||
}
|
||||
|
||||
async setInitialTranslation() {
|
||||
await Localization.setTranslation(Localization.initialLocale)
|
||||
}
|
||||
|
||||
static async setTranslation(locale) {
|
||||
if (!locale) locale = Localization.systemLocale;
|
||||
|
||||
|
|
|
@ -18,22 +18,25 @@ class PairDrop {
|
|||
const themeUI = new ThemeUI();
|
||||
const backgroundCanvas = new BackgroundCanvas();
|
||||
|
||||
Events.on('initial-translation-loaded', _ => {
|
||||
// FooterUI needs translations
|
||||
const footerUI = new FooterUI();
|
||||
|
||||
Events.on('fade-in-ui', _ => this.fadeInUI())
|
||||
Events.on('fade-in-header', _ => this.fadeInHeader())
|
||||
|
||||
// Evaluate UI elements and fade in UI
|
||||
this.evaluateUI();
|
||||
|
||||
// Load deferred assets
|
||||
this.loadDeferredAssets();
|
||||
});
|
||||
|
||||
// Translate page -> fires 'initial-translation-loaded' on finish
|
||||
// Translate page before fading in
|
||||
const localization = new Localization();
|
||||
localization
|
||||
.setInitialTranslation()
|
||||
.then(() => {
|
||||
console.log("Initial translation successful.");
|
||||
|
||||
// FooterUI needs translations
|
||||
const footerUI = new FooterUI();
|
||||
|
||||
Events.on('fade-in-ui', _ => this.fadeInUI())
|
||||
Events.on('fade-in-header', _ => this.fadeInHeader())
|
||||
|
||||
// Evaluate UI elements and fade in UI
|
||||
this.evaluateUI();
|
||||
|
||||
// Load deferred assets
|
||||
this.loadDeferredAssets();
|
||||
})
|
||||
}
|
||||
|
||||
registerServiceWorker() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue