@stemy/ngx-utils 19.8.7 → 19.8.8

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.
@@ -4269,13 +4269,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.19", ngImpo
4269
4269
  type: Injectable
4270
4270
  }], ctorParameters: () => [{ type: LocalHttpService }] });
4271
4271
 
4272
- const emptyDict = {};
4272
+ const EMPTY_DICT = {};
4273
4273
  class StaticLanguageService {
4274
4274
  get defaultLanguage() {
4275
4275
  return this.configs.getQueryParameter("lang") || this.storage.get("language", this.getDefaultLanguage());
4276
4276
  }
4277
4277
  get dictionary() {
4278
- return this.mergedTranslations[this.currentLanguage] || emptyDict;
4278
+ return this.mergedTranslations[this.currentLanguage] || EMPTY_DICT;
4279
4279
  }
4280
4280
  set dictionary(value) {
4281
4281
  this.setDictionary(this.currentLang, value);
@@ -4345,7 +4345,7 @@ class StaticLanguageService {
4345
4345
  languages = Array.isArray(languages) && languages.length > 0 ? languages : this.languageList;
4346
4346
  this.languageList = Array.from(new Set(languages));
4347
4347
  this.languageList.forEach(lang => {
4348
- this.translations[lang] = this.translations[lang] || emptyDict;
4348
+ this.translations[lang] = this.translations[lang] || EMPTY_DICT;
4349
4349
  });
4350
4350
  }
4351
4351
  addLanguages(languages) {
@@ -4451,8 +4451,8 @@ class StaticLanguageService {
4451
4451
  ]);
4452
4452
  this.mergedTranslations = Array.from(languages).reduce((merged, language) => {
4453
4453
  merged[language] = {
4454
- ...(this.translations[language] || emptyDict),
4455
- ...(this.overrideTranslations[language] || emptyDict),
4454
+ ...(this.translations[language] || EMPTY_DICT),
4455
+ ...(this.overrideTranslations[language] || EMPTY_DICT),
4456
4456
  };
4457
4457
  return merged;
4458
4458
  }, {});
@@ -4500,7 +4500,7 @@ class LanguageService extends StaticLanguageService {
4500
4500
  }
4501
4501
  initService() {
4502
4502
  super.initService();
4503
- this.client.setParam("language", "de");
4503
+ this.client.setParam("language", "en");
4504
4504
  this.translationRequests = {};
4505
4505
  this.languageSettings = new BehaviorSubject(null);
4506
4506
  if (this.universal.isServer)
@@ -4528,12 +4528,20 @@ class LanguageService extends StaticLanguageService {
4528
4528
  if (this.languageList.length === 0) {
4529
4529
  this.languageList = [defaultLanguage];
4530
4530
  }
4531
- const lang = this.languages.indexOf(defaultLanguage) < 0 ? settings.defaultLanguage || this.languageList[0] : defaultLanguage;
4531
+ const lang = this.selectLanguage(this.currentLang)
4532
+ ?? this.selectLanguage(defaultLanguage)
4533
+ ?? this.selectLanguage(settings.defaultLanguage || this.languageList[0]);
4532
4534
  await this.useLanguage(lang);
4533
4535
  this.events.languageChanged.next(lang);
4534
4536
  }
4537
+ selectLanguage(lang) {
4538
+ if (!lang)
4539
+ return null;
4540
+ return this.languageList.length === 0 || this.languageList.includes(lang)
4541
+ ? lang : null;
4542
+ }
4535
4543
  async useLanguage(lang) {
4536
- lang = this.languages.indexOf(lang) < 0 ? this.languages[0] : lang;
4544
+ lang = this.selectLanguage(lang);
4537
4545
  this.client.setParam("language", lang);
4538
4546
  if (lang === this.currentLang)
4539
4547
  return this.dictionary;
@@ -4541,8 +4549,9 @@ class LanguageService extends StaticLanguageService {
4541
4549
  this.currentLang = lang;
4542
4550
  return this.loadDictionary();
4543
4551
  }
4544
- getDictionary(lang) {
4545
- lang = this.languages.includes(lang) ? lang : this.currentLanguage;
4552
+ async getDictionary(lang) {
4553
+ if (!lang)
4554
+ return EMPTY_DICT;
4546
4555
  const ext = this.config.translationExt || ``;
4547
4556
  this.translationRequests[lang] = this.translationRequests[lang] || firstValueFrom(this.client.get(`${this.config.translationUrl}${lang}${ext}`))
4548
4557
  .then(response => {
@@ -4556,7 +4565,7 @@ class LanguageService extends StaticLanguageService {
4556
4565
  return dictionary;
4557
4566
  }).catch(error => {
4558
4567
  console.warn("Translation dictionary problem:", error);
4559
- return {};
4568
+ return EMPTY_DICT;
4560
4569
  });
4561
4570
  return this.translationRequests[lang];
4562
4571
  }
@@ -8259,7 +8268,6 @@ class InteractiveItemComponent {
8259
8268
  set rotation(value) {
8260
8269
  if (isNaN(value))
8261
8270
  return;
8262
- console.log("set rotation", this.rotation, value);
8263
8271
  this.rot = value;
8264
8272
  this.validRotation = this.rot;
8265
8273
  }
@@ -8363,7 +8371,6 @@ class InteractiveItemComponent {
8363
8371
  this.rot = isNaN(value) ? this.rot : value;
8364
8372
  this.calcShapes();
8365
8373
  this.validRot = this.checkIsValid() ? this.rot : this.validRot;
8366
- console.log("rotateTo", this.rot, this.validRot);
8367
8374
  }
8368
8375
  rotateEnd() {
8369
8376
  this.mDistances.clear();