@stemy/ngx-utils 19.7.25 → 19.7.27
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/fesm2022/stemy-ngx-utils.mjs +62 -23
- package/fesm2022/stemy-ngx-utils.mjs.map +1 -1
- package/ngx-utils/common-types.d.ts +2 -1
- package/ngx-utils/pipes/translate.pipe.d.ts +1 -1
- package/ngx-utils/services/events.service.d.ts +1 -0
- package/ngx-utils/services/language.service.d.ts +2 -1
- package/ngx-utils/services/static-language.service.d.ts +6 -2
- package/package.json +1 -1
- package/public_api.d.ts +1 -1
|
@@ -3076,6 +3076,7 @@ class EventsService {
|
|
|
3076
3076
|
this.eventForwarded = new Subject();
|
|
3077
3077
|
this.stickyUpdated = new Subject();
|
|
3078
3078
|
this.languageChanged = new Subject();
|
|
3079
|
+
this.editLanguageChanged = new Subject();
|
|
3079
3080
|
this.translationsEnabled = new Subject();
|
|
3080
3081
|
this.userChanged = new Subject();
|
|
3081
3082
|
this.sticky = false;
|
|
@@ -4189,15 +4190,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
|
|
|
4189
4190
|
type: Injectable
|
|
4190
4191
|
}], ctorParameters: () => [{ type: LocalHttpService }] });
|
|
4191
4192
|
|
|
4193
|
+
const emptyDict = {};
|
|
4192
4194
|
class StaticLanguageService {
|
|
4193
4195
|
get defaultLanguage() {
|
|
4194
4196
|
return this.configs.getQueryParameter("lang") || this.storage.get("language", this.getDefaultLanguage());
|
|
4195
4197
|
}
|
|
4196
4198
|
get dictionary() {
|
|
4197
|
-
return this.
|
|
4199
|
+
return this.mergedTranslations[this.currentLanguage] || emptyDict;
|
|
4198
4200
|
}
|
|
4199
4201
|
set dictionary(value) {
|
|
4200
4202
|
this.setDictionary(this.currentLang, value);
|
|
4203
|
+
this.mergeTranslations();
|
|
4201
4204
|
}
|
|
4202
4205
|
get languages() {
|
|
4203
4206
|
return this.languageList;
|
|
@@ -4214,6 +4217,7 @@ class StaticLanguageService {
|
|
|
4214
4217
|
}
|
|
4215
4218
|
set editLanguage(lang) {
|
|
4216
4219
|
this.editLang = lang || this.currentLanguage;
|
|
4220
|
+
this.events.editLanguageChanged.next(this.editLang);
|
|
4217
4221
|
}
|
|
4218
4222
|
get enableTranslations() {
|
|
4219
4223
|
return this.enableTrans;
|
|
@@ -4250,6 +4254,10 @@ class StaticLanguageService {
|
|
|
4250
4254
|
this.translations = {
|
|
4251
4255
|
none: {}
|
|
4252
4256
|
};
|
|
4257
|
+
this.overrideTranslations = {
|
|
4258
|
+
none: {}
|
|
4259
|
+
};
|
|
4260
|
+
this.mergedTranslations = this.translations;
|
|
4253
4261
|
this.initService();
|
|
4254
4262
|
}
|
|
4255
4263
|
initService() {
|
|
@@ -4258,7 +4266,7 @@ class StaticLanguageService {
|
|
|
4258
4266
|
languages = Array.isArray(languages) && languages.length > 0 ? languages : this.languageList;
|
|
4259
4267
|
this.languageList = Array.from(new Set(languages));
|
|
4260
4268
|
this.languageList.forEach(lang => {
|
|
4261
|
-
this.translations[lang] = this.translations[lang] ||
|
|
4269
|
+
this.translations[lang] = this.translations[lang] || emptyDict;
|
|
4262
4270
|
});
|
|
4263
4271
|
}
|
|
4264
4272
|
addLanguages(languages) {
|
|
@@ -4266,6 +4274,15 @@ class StaticLanguageService {
|
|
|
4266
4274
|
return;
|
|
4267
4275
|
this.replaceLanguages(this.languageList.concat(languages));
|
|
4268
4276
|
}
|
|
4277
|
+
setOverrideTranslations(translations) {
|
|
4278
|
+
if (ObjectUtils.isObject(translations)) {
|
|
4279
|
+
this.overrideTranslations = translations;
|
|
4280
|
+
this.mergeTranslations();
|
|
4281
|
+
return;
|
|
4282
|
+
}
|
|
4283
|
+
this.overrideTranslations = {};
|
|
4284
|
+
this.mergedTranslations = this.translations;
|
|
4285
|
+
}
|
|
4269
4286
|
getTranslationSync(key, params = null) {
|
|
4270
4287
|
key = `${key ?? ""}`;
|
|
4271
4288
|
if (!key)
|
|
@@ -4348,6 +4365,19 @@ class StaticLanguageService {
|
|
|
4348
4365
|
});
|
|
4349
4366
|
return browserLang;
|
|
4350
4367
|
}
|
|
4368
|
+
mergeTranslations() {
|
|
4369
|
+
const languages = new Set([
|
|
4370
|
+
...Object.keys(this.translations),
|
|
4371
|
+
...Object.keys(this.overrideTranslations)
|
|
4372
|
+
]);
|
|
4373
|
+
this.mergedTranslations = Array.from(languages).reduce((merged, language) => {
|
|
4374
|
+
merged[language] = {
|
|
4375
|
+
...(this.translations[language] || emptyDict),
|
|
4376
|
+
...(this.overrideTranslations[language] || emptyDict),
|
|
4377
|
+
};
|
|
4378
|
+
return merged;
|
|
4379
|
+
}, {});
|
|
4380
|
+
}
|
|
4351
4381
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: StaticLanguageService, deps: [{ token: EventsService }, { token: StorageService }, { token: CONFIG_SERVICE }, { token: PROMISE_SERVICE }, { token: BaseHttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
4352
4382
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: StaticLanguageService }); }
|
|
4353
4383
|
}
|
|
@@ -4432,26 +4462,33 @@ class LanguageService extends StaticLanguageService {
|
|
|
4432
4462
|
this.currentLang = lang;
|
|
4433
4463
|
return this.loadDictionary();
|
|
4434
4464
|
}
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4465
|
+
getDictionary(lang) {
|
|
4466
|
+
lang = this.languages.includes(lang) ? lang : this.currentLanguage;
|
|
4467
|
+
const ext = this.config.translationExt || ``;
|
|
4468
|
+
this.translationRequests[lang] = this.translationRequests[lang] || firstValueFrom(this.client.get(`${this.config.translationUrl}${lang}${ext}`))
|
|
4469
|
+
.then(response => {
|
|
4470
|
+
response = response || {};
|
|
4471
|
+
const dictionary = Object.keys(response).reduce((result, key) => {
|
|
4472
|
+
result[key.toLocaleLowerCase()] = response[key];
|
|
4473
|
+
return result;
|
|
4474
|
+
}, {});
|
|
4475
|
+
this.translations[lang] = dictionary;
|
|
4476
|
+
this.mergeTranslations();
|
|
4477
|
+
return dictionary;
|
|
4478
|
+
}).catch(error => {
|
|
4479
|
+
console.warn("Translation dictionary problem:", error);
|
|
4480
|
+
return {};
|
|
4446
4481
|
});
|
|
4447
4482
|
return this.translationRequests[lang];
|
|
4448
4483
|
}
|
|
4484
|
+
async loadDictionary() {
|
|
4485
|
+
return this.getDictionary(this.currentLang);
|
|
4486
|
+
}
|
|
4449
4487
|
loadSettings() {
|
|
4450
4488
|
const ext = this.config.translationExt || ``;
|
|
4451
|
-
this.settingsPromise = this.settingsPromise || (this.client.get(`${this.config.translationUrl}languageSettings${ext}`)
|
|
4452
|
-
.
|
|
4453
|
-
|
|
4454
|
-
}, () => {
|
|
4489
|
+
this.settingsPromise = this.settingsPromise || firstValueFrom(this.client.get(`${this.config.translationUrl}languageSettings${ext}`))
|
|
4490
|
+
.catch(error => {
|
|
4491
|
+
console.warn("Translation settings problem:", error);
|
|
4455
4492
|
return {
|
|
4456
4493
|
languages: ["de", "en", "hu"],
|
|
4457
4494
|
devLanguages: [],
|
|
@@ -5843,9 +5880,9 @@ class TranslatePipe {
|
|
|
5843
5880
|
if (!query)
|
|
5844
5881
|
return "";
|
|
5845
5882
|
let dirty = false;
|
|
5846
|
-
const
|
|
5847
|
-
if (this.
|
|
5848
|
-
this.
|
|
5883
|
+
const dictionary = this.language.dictionary;
|
|
5884
|
+
if (this.dictionary !== dictionary) {
|
|
5885
|
+
this.dictionary = dictionary;
|
|
5849
5886
|
dirty = true;
|
|
5850
5887
|
}
|
|
5851
5888
|
const enabled = this.language.enableTranslations;
|
|
@@ -5880,7 +5917,9 @@ class TranslatePipe {
|
|
|
5880
5917
|
}
|
|
5881
5918
|
if (dirty) {
|
|
5882
5919
|
if (typeof query === "object") {
|
|
5883
|
-
this.lastValue = Array.isArray(query)
|
|
5920
|
+
this.lastValue = Array.isArray(query)
|
|
5921
|
+
? this.language.getTranslationFromArray(query, this.params)
|
|
5922
|
+
: this.language.getTranslationFromObject(query, this.params);
|
|
5884
5923
|
return this.lastValue;
|
|
5885
5924
|
}
|
|
5886
5925
|
this.lastValue = this.language.getTranslationSync(query, this.params);
|
|
@@ -7320,10 +7359,10 @@ class ChipsComponent {
|
|
|
7320
7359
|
}
|
|
7321
7360
|
return false;
|
|
7322
7361
|
}
|
|
7323
|
-
if (ev.key
|
|
7362
|
+
if (ev.key === "Enter" || ev.key === "Tab") {
|
|
7324
7363
|
return this.enterOption(input.value);
|
|
7325
7364
|
}
|
|
7326
|
-
if (ev.key
|
|
7365
|
+
if (ev.key === "Backspace" && !input.value && !changed && this.valueOptions.length > 0) {
|
|
7327
7366
|
this.makeUndo();
|
|
7328
7367
|
this.updateValues(this.valueOptions.slice(0, this.valueOptions.length - 1));
|
|
7329
7368
|
this.onTouched(this.value);
|