@stemy/ngx-utils 19.8.7 → 19.8.9

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) {
@@ -4414,7 +4414,8 @@ class StaticLanguageService {
4414
4414
  }
4415
4415
  interpolate(expr, params) {
4416
4416
  if (typeof expr === "string") {
4417
- return this.interpolateString(expr, params);
4417
+ // Force single spaces to be empty strings, for labeling in forms.
4418
+ return expr === " " ? "" : this.interpolateString(expr, params);
4418
4419
  }
4419
4420
  if (typeof expr === "function") {
4420
4421
  return expr(params);
@@ -4451,8 +4452,8 @@ class StaticLanguageService {
4451
4452
  ]);
4452
4453
  this.mergedTranslations = Array.from(languages).reduce((merged, language) => {
4453
4454
  merged[language] = {
4454
- ...(this.translations[language] || emptyDict),
4455
- ...(this.overrideTranslations[language] || emptyDict),
4455
+ ...(this.translations[language] || EMPTY_DICT),
4456
+ ...(this.overrideTranslations[language] || EMPTY_DICT),
4456
4457
  };
4457
4458
  return merged;
4458
4459
  }, {});
@@ -4500,7 +4501,7 @@ class LanguageService extends StaticLanguageService {
4500
4501
  }
4501
4502
  initService() {
4502
4503
  super.initService();
4503
- this.client.setParam("language", "de");
4504
+ this.client.setParam("language", "en");
4504
4505
  this.translationRequests = {};
4505
4506
  this.languageSettings = new BehaviorSubject(null);
4506
4507
  if (this.universal.isServer)
@@ -4528,12 +4529,20 @@ class LanguageService extends StaticLanguageService {
4528
4529
  if (this.languageList.length === 0) {
4529
4530
  this.languageList = [defaultLanguage];
4530
4531
  }
4531
- const lang = this.languages.indexOf(defaultLanguage) < 0 ? settings.defaultLanguage || this.languageList[0] : defaultLanguage;
4532
+ const lang = this.selectLanguage(this.currentLang)
4533
+ ?? this.selectLanguage(defaultLanguage)
4534
+ ?? this.selectLanguage(settings.defaultLanguage || this.languageList[0]);
4532
4535
  await this.useLanguage(lang);
4533
4536
  this.events.languageChanged.next(lang);
4534
4537
  }
4538
+ selectLanguage(lang) {
4539
+ if (!lang)
4540
+ return null;
4541
+ return this.languageList.length === 0 || this.languageList.includes(lang)
4542
+ ? lang : null;
4543
+ }
4535
4544
  async useLanguage(lang) {
4536
- lang = this.languages.indexOf(lang) < 0 ? this.languages[0] : lang;
4545
+ lang = this.selectLanguage(lang);
4537
4546
  this.client.setParam("language", lang);
4538
4547
  if (lang === this.currentLang)
4539
4548
  return this.dictionary;
@@ -4541,8 +4550,9 @@ class LanguageService extends StaticLanguageService {
4541
4550
  this.currentLang = lang;
4542
4551
  return this.loadDictionary();
4543
4552
  }
4544
- getDictionary(lang) {
4545
- lang = this.languages.includes(lang) ? lang : this.currentLanguage;
4553
+ async getDictionary(lang) {
4554
+ if (!lang)
4555
+ return EMPTY_DICT;
4546
4556
  const ext = this.config.translationExt || ``;
4547
4557
  this.translationRequests[lang] = this.translationRequests[lang] || firstValueFrom(this.client.get(`${this.config.translationUrl}${lang}${ext}`))
4548
4558
  .then(response => {
@@ -4556,7 +4566,7 @@ class LanguageService extends StaticLanguageService {
4556
4566
  return dictionary;
4557
4567
  }).catch(error => {
4558
4568
  console.warn("Translation dictionary problem:", error);
4559
- return {};
4569
+ return EMPTY_DICT;
4560
4570
  });
4561
4571
  return this.translationRequests[lang];
4562
4572
  }
@@ -8259,7 +8269,6 @@ class InteractiveItemComponent {
8259
8269
  set rotation(value) {
8260
8270
  if (isNaN(value))
8261
8271
  return;
8262
- console.log("set rotation", this.rotation, value);
8263
8272
  this.rot = value;
8264
8273
  this.validRotation = this.rot;
8265
8274
  }
@@ -8363,7 +8372,6 @@ class InteractiveItemComponent {
8363
8372
  this.rot = isNaN(value) ? this.rot : value;
8364
8373
  this.calcShapes();
8365
8374
  this.validRot = this.checkIsValid() ? this.rot : this.validRot;
8366
- console.log("rotateTo", this.rot, this.validRot);
8367
8375
  }
8368
8376
  rotateEnd() {
8369
8377
  this.mDistances.clear();