@sumaris-net/ngx-components 2.5.16-rc2 → 2.5.16

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.
@@ -18757,26 +18757,12 @@ class PlatformService extends StartableService {
18757
18757
  console.info('[platform] Configuring i18n ...');
18758
18758
  // this language will be used as a fallback when a translation isn't found in the current language
18759
18759
  this.translate.setDefaultLang(this.environment.defaultLocale);
18760
- this.dateAdapter.setLocale(this.environment.defaultLocale);
18760
+ // apply locale immediately
18761
+ this.applyLocale(this.environment.defaultLocale);
18761
18762
  // When locale changes, apply to date adapter
18762
18763
  this.registerSubscription(this.translate.onLangChange.subscribe(event => {
18763
18764
  if (event && event.lang) {
18764
- // force 'en' as 'en_GB'
18765
- if (event.lang === 'en') {
18766
- event.lang = 'en_GB';
18767
- }
18768
- // config moment lib
18769
- try {
18770
- locale(event.lang);
18771
- console.debug('[platform] Use locale {' + event.lang + '}');
18772
- }
18773
- // If error, fallback to en
18774
- catch (err) {
18775
- locale('en');
18776
- console.warn('[platform] Unknown locale for moment lib. Using default [en]');
18777
- }
18778
- // Config date adapter
18779
- this.dateAdapter.setLocale(locale());
18765
+ this.applyLocale(event.lang);
18780
18766
  }
18781
18767
  }));
18782
18768
  this.registerSubscription(this.settings.onChange.subscribe(data => {
@@ -18801,6 +18787,24 @@ class PlatformService extends StartableService {
18801
18787
  }
18802
18788
  }));
18803
18789
  }
18790
+ applyLocale(locale$1) {
18791
+ // force 'en' as 'en_GB'
18792
+ if (locale$1 === 'en') {
18793
+ locale$1 = 'en_GB';
18794
+ }
18795
+ // config moment lib
18796
+ try {
18797
+ locale(locale$1);
18798
+ console.debug('[platform] Use locale {' + locale$1 + '}');
18799
+ }
18800
+ // If error, fallback to en
18801
+ catch (err) {
18802
+ locale('en');
18803
+ console.warn('[platform] Unknown locale for moment lib. Using default [en]');
18804
+ }
18805
+ // Config date adapter
18806
+ this.dateAdapter.setLocale(locale());
18807
+ }
18804
18808
  configureCache(online) {
18805
18809
  online = toBoolean(online, this.cache.isOnline());
18806
18810
  const cacheTTL = online ? 3600 /* 1h */ : 3600 * 24 * 30; /* 1 month */