mn-angular-lib 0.0.47 → 0.0.48

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.
@@ -631,6 +631,17 @@ class MnLanguageService {
631
631
  t(key, params) {
632
632
  return this.translate(key, params);
633
633
  }
634
+ /**
635
+ * Resolve the effective default locale from a domain-to-locale map.
636
+ * Matches `window.location.hostname` against the map keys.
637
+ * Returns the mapped locale, or the provided fallback if no match is found.
638
+ */
639
+ resolveLocaleForDomain(domainLocaleMap, fallback) {
640
+ if (!domainLocaleMap || typeof window === 'undefined')
641
+ return fallback;
642
+ const hostname = window.location.hostname;
643
+ return domainLocaleMap[hostname] ?? fallback;
644
+ }
634
645
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: MnLanguageService, deps: [{ token: i1$1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
635
646
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: MnLanguageService, providedIn: 'root' });
636
647
  }
@@ -695,9 +706,10 @@ class MnConfigService {
695
706
  if (isPlainObject(langCfg) && typeof langCfg['urlPattern'] === 'string') {
696
707
  const lc = langCfg;
697
708
  this.lang.configure(lc.urlPattern);
698
- const localesToLoad = lc.preload ?? [lc.defaultLocale];
709
+ const effectiveLocale = this.lang.resolveLocaleForDomain(lc.domainLocaleMap, lc.defaultLocale);
710
+ const localesToLoad = lc.preload ?? [effectiveLocale];
699
711
  await Promise.all(localesToLoad.map(l => this.lang.loadLocale(l)));
700
- await this.lang.setLocale(lc.defaultLocale);
712
+ await this.lang.setLocale(effectiveLocale);
701
713
  }
702
714
  }
703
715
  /**
@@ -4703,9 +4715,10 @@ function provideMnLanguage(config) {
4703
4715
  multi: true,
4704
4716
  useFactory: (svc) => async () => {
4705
4717
  svc.configure(config.urlPattern);
4706
- const localesToLoad = config.preload ?? [config.defaultLocale];
4718
+ const effectiveLocale = svc.resolveLocaleForDomain(config.domainLocaleMap, config.defaultLocale);
4719
+ const localesToLoad = config.preload ?? [effectiveLocale];
4707
4720
  await Promise.all(localesToLoad.map(l => svc.loadLocale(l)));
4708
- await svc.setLocale(config.defaultLocale);
4721
+ await svc.setLocale(effectiveLocale);
4709
4722
  },
4710
4723
  deps: [MnLanguageService],
4711
4724
  },