@dialpad/i18n 1.19.0 → 1.22.1

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/i18n.js CHANGED
@@ -6646,7 +6646,7 @@ class BaseLocaleManager {
6646
6646
  if (this._resolveReady) this._resolveReady(null);
6647
6647
  }
6648
6648
  initFluent() {
6649
- return createFluentVue({ bundles: this.currentBundles });
6649
+ return this.fluent ?? (this.fluent = createFluentVue({ bundles: this.currentBundles }));
6650
6650
  }
6651
6651
  determineLocale({
6652
6652
  preferredLocale,
@@ -6809,9 +6809,7 @@ class LocaleManager extends BaseLocaleManager {
6809
6809
  * Defaults to 'default'
6810
6810
  */
6811
6811
  install(app, namespace = "default") {
6812
- if (this.fluent === null) {
6813
- this.fluent = this.initFluent();
6814
- }
6812
+ this.initFluent();
6815
6813
  this.addToVue(app, namespace);
6816
6814
  }
6817
6815
  addToVue(app, namespace) {
@@ -6883,6 +6881,22 @@ class LocaleManager extends BaseLocaleManager {
6883
6881
  });
6884
6882
  return localeManagers;
6885
6883
  }
6884
+ useI18N(namespace = "default") {
6885
+ this.initFluent();
6886
+ const l = this;
6887
+ return {
6888
+ currentLocale: computed(() => this.currentLocaleProp.value),
6889
+ setI18N: (args, namespace2) => {
6890
+ l.changeLocale(args, namespace2);
6891
+ },
6892
+ get $t() {
6893
+ return l.fluentFormat;
6894
+ },
6895
+ get $ta() {
6896
+ return l.fluentFormatAttrs;
6897
+ }
6898
+ };
6899
+ }
6886
6900
  }
6887
6901
  function findLocaleManager(namespace) {
6888
6902
  const injectionKey = parseInjectionName(namespace);
@@ -6896,14 +6910,7 @@ function useI18N(namespace = "default") {
6896
6910
  `locale manager doesn't exist using ${namespace}. Make sure your locale manager was set up correctly`
6897
6911
  );
6898
6912
  }
6899
- return {
6900
- currentLocale: computed(() => localeManager.currentLocaleProp.value),
6901
- setI18N: (args, namespace2) => {
6902
- localeManager.changeLocale(args, namespace2);
6903
- },
6904
- $t: localeManager.fluentFormat,
6905
- $ta: localeManager.fluentFormatAttrs
6906
- };
6913
+ return localeManager.useI18N(namespace);
6907
6914
  }
6908
6915
  function parseInjectionName(namespace) {
6909
6916
  return `${INJECTION_KEY_PREFIX}.${namespace}`;