langsys-js-typescript 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +18 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -440,6 +440,19 @@ var Translations = class {
|
|
|
440
440
|
this.debug.log(`SSR environment detected - using '${strategy}' token strategy`);
|
|
441
441
|
}
|
|
442
442
|
}
|
|
443
|
+
/**
|
|
444
|
+
* Record that a locale's catalog is already present without fetching —
|
|
445
|
+
* e.g. after an SSR handoff seeds `sTranslations` + `currentlyLoadedLocale`.
|
|
446
|
+
* This primes the same `lastLoaded` cache `change()` consults, so the first
|
|
447
|
+
* settle for that locale is a cache hit (no redundant fetch) while every
|
|
448
|
+
* later switch *to* it still flows through `change()` normally.
|
|
449
|
+
*/
|
|
450
|
+
markLoaded(locale) {
|
|
451
|
+
if (!locale) return;
|
|
452
|
+
this.locale = locale;
|
|
453
|
+
this.lastLoaded[locale] = (/* @__PURE__ */ new Date()).getTime() / 1e3;
|
|
454
|
+
this.readyResolve();
|
|
455
|
+
}
|
|
443
456
|
/**
|
|
444
457
|
* React to a user-locale change. Fetches translations if we haven't
|
|
445
458
|
* loaded this locale within the last 60s (or if forced).
|
|
@@ -451,6 +464,7 @@ var Translations = class {
|
|
|
451
464
|
this.debug.log("Using pre-fetched translations for locale", locale);
|
|
452
465
|
this.locale = locale;
|
|
453
466
|
this.lastLoaded[locale] = (/* @__PURE__ */ new Date()).getTime() / 1e3;
|
|
467
|
+
this.readyResolve();
|
|
454
468
|
return true;
|
|
455
469
|
}
|
|
456
470
|
const now = (/* @__PURE__ */ new Date()).getTime() / 1e3;
|
|
@@ -654,12 +668,14 @@ var LangsysAppClass = class {
|
|
|
654
668
|
this.debug.log("Populated sTranslations with initial data for locale:", initialTranslationsLocale);
|
|
655
669
|
}
|
|
656
670
|
this.Translations.setup(this.config);
|
|
671
|
+
if (initialTranslations2 && initialTranslationsLocale) {
|
|
672
|
+
this.Translations.markLoaded(initialTranslationsLocale);
|
|
673
|
+
}
|
|
657
674
|
this.config.sUserLocale.subscribe((locale) => {
|
|
658
675
|
if (!validateResponse.status) return;
|
|
659
676
|
this.getLocalesData(locale);
|
|
660
677
|
this.debug.log("SUBSCRIBING TO USER LOCALE STORE");
|
|
661
|
-
|
|
662
|
-
this.translationsLoadingPromise = this.Translations.change(locale, false, skipFetch);
|
|
678
|
+
this.translationsLoadingPromise = this.Translations.change(locale, false);
|
|
663
679
|
});
|
|
664
680
|
return validateResponse;
|
|
665
681
|
}
|