@o3r/localization 15.3.0-prerelease.8 → 15.3.0-rc.1
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/o3r-localization-rules-engine.mjs +89 -56
- package/fesm2022/o3r-localization-rules-engine.mjs.map +1 -1
- package/fesm2022/o3r-localization.mjs +1219 -1162
- package/fesm2022/o3r-localization.mjs.map +1 -1
- package/package.json +7 -7
- package/schematics/ng-add/schema.json +0 -3
- package/types/o3r-localization-rules-engine.d.ts +21 -27
- package/types/o3r-localization-rules-engine.d.ts.map +1 -1
- package/types/o3r-localization.d.ts +637 -664
- package/types/o3r-localization.d.ts.map +1 -1
|
@@ -1,1190 +1,1247 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import * as i0 from
|
|
3
|
-
import {
|
|
4
|
-
import { TranslateCompiler,
|
|
5
|
-
import { IntlMessageFormat } from
|
|
6
|
-
import { BehaviorSubject, combineLatest, firstValueFrom,
|
|
7
|
-
import * as i1 from
|
|
8
|
-
import {
|
|
9
|
-
import { LoggerService } from
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { CurrencyPipe, DatePipe, DecimalPipe
|
|
13
|
-
import { DynamicContentService } from
|
|
14
|
-
import { takeUntilDestroyed } from
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Decorator to pass localization url
|
|
18
|
-
* @param _url
|
|
19
|
-
*/
|
|
20
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention -- decorator should start with a capital letter
|
|
1
|
+
import { deepFill, filterMessageContent, immutablePrimitive, otterComponentInfoPropertyName, sendOtterMessage } from "@o3r/core";
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
import { ApplicationRef, ChangeDetectorRef, DestroyRef, Directive, ElementRef, Injectable, InjectionToken, Injector, Input, LOCALE_ID, NgModule, Optional, Pipe, RendererFactory2, inject } from "@angular/core";
|
|
4
|
+
import { TranslateCompiler, TranslateDirective, TranslateLoader, TranslateModule, TranslatePipe, TranslateService } from "@ngx-translate/core";
|
|
5
|
+
import { IntlMessageFormat } from "intl-messageformat";
|
|
6
|
+
import { BehaviorSubject, combineLatest, firstValueFrom, from, fromEvent, lastValueFrom, of } from "rxjs";
|
|
7
|
+
import * as i1 from "@ngrx/store";
|
|
8
|
+
import { Store, StoreModule, createAction, createFeatureSelector, createReducer, createSelector, on, props, select } from "@ngrx/store";
|
|
9
|
+
import { LoggerService } from "@o3r/logger";
|
|
10
|
+
import { catchError, distinctUntilChanged, map, shareReplay, startWith, switchMap } from "rxjs/operators";
|
|
11
|
+
import { BidiModule, Directionality } from "@angular/cdk/bidi";
|
|
12
|
+
import { CommonModule, CurrencyPipe, DatePipe, DecimalPipe } from "@angular/common";
|
|
13
|
+
import { DynamicContentService } from "@o3r/dynamic-content";
|
|
14
|
+
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
|
21
15
|
function Localization(_url) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
configurable: true
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
};
|
|
16
|
+
return (target, key) => {
|
|
17
|
+
const privateField = _url || `_${key}`;
|
|
18
|
+
const privateValue = target[key];
|
|
19
|
+
if (delete target[key]) Object.defineProperty(target, key, {
|
|
20
|
+
get: function() {
|
|
21
|
+
return this[privateField];
|
|
22
|
+
},
|
|
23
|
+
set: function(value) {
|
|
24
|
+
const currentField = this[privateField] || privateValue;
|
|
25
|
+
this[privateField] = typeof currentField === "undefined" ? immutablePrimitive(value) : deepFill(currentField, value);
|
|
26
|
+
if (this[otterComponentInfoPropertyName]) this[otterComponentInfoPropertyName].translations = this[privateField];
|
|
27
|
+
},
|
|
28
|
+
enumerable: true,
|
|
29
|
+
configurable: true
|
|
30
|
+
});
|
|
31
|
+
};
|
|
42
32
|
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Default configuration for LocalizationModule
|
|
46
|
-
*/
|
|
47
33
|
const DEFAULT_LOCALIZATION_CONFIGURATION = {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
34
|
+
supportedLocales: [],
|
|
35
|
+
endPointUrl: "",
|
|
36
|
+
useDynamicContent: false,
|
|
37
|
+
rtlLanguages: ["ar", "he"],
|
|
38
|
+
fallbackLanguage: "en",
|
|
39
|
+
bundlesOutputPath: "",
|
|
40
|
+
debugMode: false,
|
|
41
|
+
enableTranslationDeactivation: false,
|
|
42
|
+
mergeWithLocalTranslations: false
|
|
57
43
|
};
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Message format configuration default value
|
|
61
|
-
*/
|
|
62
44
|
const lazyMessageDefaultConfig = {
|
|
63
|
-
|
|
64
|
-
|
|
45
|
+
enableCache: true,
|
|
46
|
+
ignoreTag: true
|
|
65
47
|
};
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
*/
|
|
48
|
+
const MESSAGE_FORMAT_CONFIG = new InjectionToken("Message Format configuration");
|
|
49
|
+
var TranslateMessageFormatLazyCompiler = class TranslateMessageFormatLazyCompiler extends TranslateCompiler {
|
|
50
|
+
constructor() {
|
|
51
|
+
const config = inject(MESSAGE_FORMAT_CONFIG, { optional: true });
|
|
52
|
+
super();
|
|
53
|
+
this.cache = {};
|
|
54
|
+
this.config = config ? {
|
|
55
|
+
...lazyMessageDefaultConfig,
|
|
56
|
+
...config
|
|
57
|
+
} : lazyMessageDefaultConfig;
|
|
58
|
+
}
|
|
59
|
+
clearCache() {
|
|
60
|
+
this.cache = {};
|
|
61
|
+
}
|
|
62
|
+
compile(value, lang) {
|
|
63
|
+
return (params) => new IntlMessageFormat(value, lang, void 0, this.config).format(params);
|
|
64
|
+
}
|
|
65
|
+
compileTranslations(translations, lang) {
|
|
66
|
+
const compilingStrategy = this.config.enableCache ? (acc, key) => {
|
|
67
|
+
acc[key] = (params) => {
|
|
68
|
+
const cached = this.cache[`${lang}_${key}`];
|
|
69
|
+
if (cached) return cached.format(params);
|
|
70
|
+
const newCachedItem = new IntlMessageFormat(translations[key], lang, void 0, this.config);
|
|
71
|
+
this.cache[`${lang}_${key}`] = newCachedItem;
|
|
72
|
+
return newCachedItem.format(params);
|
|
73
|
+
};
|
|
74
|
+
return acc;
|
|
75
|
+
} : (acc, key) => {
|
|
76
|
+
acc[key] = (params) => new IntlMessageFormat(translations[key], lang, void 0, this.config).format(params);
|
|
77
|
+
return acc;
|
|
78
|
+
};
|
|
79
|
+
return Object.keys(translations).reduce((acc, key) => compilingStrategy(acc, key), {});
|
|
80
|
+
}
|
|
81
|
+
static {
|
|
82
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
83
|
+
minVersion: "12.0.0",
|
|
84
|
+
version: "22.2.3",
|
|
85
|
+
ngImport: i0,
|
|
86
|
+
type: TranslateMessageFormatLazyCompiler,
|
|
87
|
+
deps: [],
|
|
88
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
static {
|
|
92
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
93
|
+
minVersion: "12.0.0",
|
|
94
|
+
version: "22.2.3",
|
|
95
|
+
ngImport: i0,
|
|
96
|
+
type: TranslateMessageFormatLazyCompiler
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
101
|
+
minVersion: "12.0.0",
|
|
102
|
+
version: "22.2.3",
|
|
103
|
+
ngImport: i0,
|
|
104
|
+
type: TranslateMessageFormatLazyCompiler,
|
|
105
|
+
decorators: [{ type: Injectable }],
|
|
106
|
+
ctorParameters: () => []
|
|
107
|
+
});
|
|
108
|
+
const setLocalizationOverride = createAction("[LocalizationOverride] set", props());
|
|
128
109
|
const localizationOverrideInitialState = { localizationOverrides: {} };
|
|
129
|
-
|
|
130
|
-
* List of basic actions for LocalizationOverride Store
|
|
131
|
-
*/
|
|
132
|
-
const localizationOverrideReducerFeatures = [
|
|
133
|
-
on(setLocalizationOverride, (_state, payload) => ({ ...payload.state }))
|
|
134
|
-
];
|
|
135
|
-
/**
|
|
136
|
-
* LocalizationOverride Store reducer
|
|
137
|
-
*/
|
|
110
|
+
const localizationOverrideReducerFeatures = [on(setLocalizationOverride, (_state, payload) => ({ ...payload.state }))];
|
|
138
111
|
const localizationOverrideReducer = createReducer(localizationOverrideInitialState, ...localizationOverrideReducerFeatures);
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
* Name of the LocalizationOverride Store
|
|
142
|
-
*/
|
|
143
|
-
const LOCALIZATION_OVERRIDE_STORE_NAME = 'localizationOverride';
|
|
144
|
-
|
|
145
|
-
/** Token of the LocalizationOverride reducer */
|
|
146
|
-
const LOCALIZATION_OVERRIDE_REDUCER_TOKEN = new InjectionToken('Feature LocalizationOverride Reducer');
|
|
147
|
-
/** Provide default reducer for LocalizationOverride store */
|
|
112
|
+
const LOCALIZATION_OVERRIDE_STORE_NAME = "localizationOverride";
|
|
113
|
+
const LOCALIZATION_OVERRIDE_REDUCER_TOKEN = new InjectionToken("Feature LocalizationOverride Reducer");
|
|
148
114
|
function getDefaultLocalizationOverrideReducer() {
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
class LocalizationOverrideStoreModule {
|
|
152
|
-
static forRoot(reducerFactory) {
|
|
153
|
-
return {
|
|
154
|
-
ngModule: LocalizationOverrideStoreModule,
|
|
155
|
-
providers: [
|
|
156
|
-
{ provide: LOCALIZATION_OVERRIDE_REDUCER_TOKEN, useFactory: reducerFactory }
|
|
157
|
-
]
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: LocalizationOverrideStoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
161
|
-
/** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "22.2.0", ngImport: i0, type: LocalizationOverrideStoreModule, imports: [i1.StoreFeatureModule] }); }
|
|
162
|
-
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: LocalizationOverrideStoreModule, providers: [
|
|
163
|
-
{ provide: LOCALIZATION_OVERRIDE_REDUCER_TOKEN, useFactory: getDefaultLocalizationOverrideReducer }
|
|
164
|
-
], imports: [StoreModule.forFeature(LOCALIZATION_OVERRIDE_STORE_NAME, LOCALIZATION_OVERRIDE_REDUCER_TOKEN)] }); }
|
|
115
|
+
return localizationOverrideReducer;
|
|
165
116
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
117
|
+
var LocalizationOverrideStoreModule = class LocalizationOverrideStoreModule {
|
|
118
|
+
static forRoot(reducerFactory) {
|
|
119
|
+
return {
|
|
120
|
+
ngModule: LocalizationOverrideStoreModule,
|
|
121
|
+
providers: [{
|
|
122
|
+
provide: LOCALIZATION_OVERRIDE_REDUCER_TOKEN,
|
|
123
|
+
useFactory: reducerFactory
|
|
124
|
+
}]
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
static {
|
|
128
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
129
|
+
minVersion: "12.0.0",
|
|
130
|
+
version: "22.2.3",
|
|
131
|
+
ngImport: i0,
|
|
132
|
+
type: LocalizationOverrideStoreModule,
|
|
133
|
+
deps: [],
|
|
134
|
+
target: i0.ɵɵFactoryTarget.NgModule
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
static {
|
|
138
|
+
this.ɵmod = i0.ɵɵngDeclareNgModule({
|
|
139
|
+
minVersion: "14.0.0",
|
|
140
|
+
version: "22.2.3",
|
|
141
|
+
ngImport: i0,
|
|
142
|
+
type: LocalizationOverrideStoreModule,
|
|
143
|
+
imports: [i1.StoreFeatureModule]
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
static {
|
|
147
|
+
this.ɵinj = i0.ɵɵngDeclareInjector({
|
|
148
|
+
minVersion: "12.0.0",
|
|
149
|
+
version: "22.2.3",
|
|
150
|
+
ngImport: i0,
|
|
151
|
+
type: LocalizationOverrideStoreModule,
|
|
152
|
+
providers: [{
|
|
153
|
+
provide: LOCALIZATION_OVERRIDE_REDUCER_TOKEN,
|
|
154
|
+
useFactory: getDefaultLocalizationOverrideReducer
|
|
155
|
+
}],
|
|
156
|
+
imports: [StoreModule.forFeature(LOCALIZATION_OVERRIDE_STORE_NAME, LOCALIZATION_OVERRIDE_REDUCER_TOKEN)]
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
161
|
+
minVersion: "12.0.0",
|
|
162
|
+
version: "22.2.3",
|
|
163
|
+
ngImport: i0,
|
|
164
|
+
type: LocalizationOverrideStoreModule,
|
|
165
|
+
decorators: [{
|
|
166
|
+
type: NgModule,
|
|
167
|
+
args: [{
|
|
168
|
+
imports: [StoreModule.forFeature(LOCALIZATION_OVERRIDE_STORE_NAME, LOCALIZATION_OVERRIDE_REDUCER_TOKEN)],
|
|
169
|
+
providers: [{
|
|
170
|
+
provide: LOCALIZATION_OVERRIDE_REDUCER_TOKEN,
|
|
171
|
+
useFactory: getDefaultLocalizationOverrideReducer
|
|
172
|
+
}]
|
|
173
|
+
}]
|
|
174
|
+
}]
|
|
175
|
+
});
|
|
179
176
|
const selectLocalizationOverrideState = createFeatureSelector(LOCALIZATION_OVERRIDE_STORE_NAME);
|
|
180
|
-
/** Select all localization override map */
|
|
181
177
|
const selectLocalizationOverride = createSelector(selectLocalizationOverrideState, (state) => state?.localizationOverrides || {});
|
|
182
|
-
|
|
183
178
|
const localizationOverrideStorageDeserializer = (rawObject) => {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
}
|
|
187
|
-
return rawObject;
|
|
179
|
+
if (!rawObject) return localizationOverrideInitialState;
|
|
180
|
+
return rawObject;
|
|
188
181
|
};
|
|
189
|
-
const localizationOverrideStorageSync = {
|
|
190
|
-
|
|
182
|
+
const localizationOverrideStorageSync = { deserialize: localizationOverrideStorageDeserializer };
|
|
183
|
+
const LOCALIZATION_CONFIGURATION_TOKEN = new InjectionToken("Localization Configuration injection token");
|
|
184
|
+
var LocalizationService = class LocalizationService {
|
|
185
|
+
constructor() {
|
|
186
|
+
this.translateService = inject(TranslateService);
|
|
187
|
+
this.logger = inject(LoggerService);
|
|
188
|
+
this.configuration = inject(LOCALIZATION_CONFIGURATION_TOKEN);
|
|
189
|
+
this.store = inject(Store, { optional: true });
|
|
190
|
+
this.localeSplitIdentifier = "-";
|
|
191
|
+
this._showKeys$ = new BehaviorSubject(false);
|
|
192
|
+
this.showKeys$ = this._showKeys$.asObservable();
|
|
193
|
+
this.configure();
|
|
194
|
+
if (this.store) this.keyMapping$ = this.store.pipe(select(selectLocalizationOverride));
|
|
195
|
+
}
|
|
196
|
+
checkFallbackLocalesMap(language) {
|
|
197
|
+
if (language && !this.configuration.supportedLocales.includes(language)) {
|
|
198
|
+
const closestSupportedLanguageCode = this.getFirstClosestSupportedLanguageCode(language);
|
|
199
|
+
const fallbackForLanguage = this.getFallbackMapLangCode(language);
|
|
200
|
+
const fallbackStrategyDebug = fallbackForLanguage && " associated fallback language " || closestSupportedLanguageCode && " closest supported language " || this.configuration.fallbackLanguage && " configured default language ";
|
|
201
|
+
const fallbackLang = fallbackForLanguage || closestSupportedLanguageCode || this.configuration.fallbackLanguage || language;
|
|
202
|
+
if (language !== fallbackLang) this.logger.debug(`Non supported languages ${language} will fallback to ${fallbackStrategyDebug} ${fallbackLang}`);
|
|
203
|
+
return fallbackLang;
|
|
204
|
+
} else if (!language) this.logger.debug("Language is not defined");
|
|
205
|
+
return language;
|
|
206
|
+
}
|
|
207
|
+
getFallbackMapLangCode(language) {
|
|
208
|
+
const fallbackLocalesMap = this.configuration.fallbackLocalesMap;
|
|
209
|
+
const [locale] = language.split(this.localeSplitIdentifier);
|
|
210
|
+
return fallbackLocalesMap && (fallbackLocalesMap[language] || fallbackLocalesMap[locale]);
|
|
211
|
+
}
|
|
212
|
+
getFirstClosestSupportedLanguageCode(language) {
|
|
213
|
+
const [locale] = language.split(this.localeSplitIdentifier);
|
|
214
|
+
const firstClosestRegx = new RegExp(`^${locale}${this.localeSplitIdentifier}?`, "i");
|
|
215
|
+
return this.configuration.supportedLocales.find((supportedLang) => firstClosestRegx.test(supportedLang));
|
|
216
|
+
}
|
|
217
|
+
getTranslationStream(translationKey, interpolateParams) {
|
|
218
|
+
const translation$ = this.translateService.onTranslationChange.pipe(startWith(void 0), switchMap(() => this.translateService.stream(translationKey, interpolateParams)), map((value) => this.configuration.debugMode ? `${translationKey} - ${value}` : value), distinctUntilChanged());
|
|
219
|
+
if (!this.configuration.enableTranslationDeactivation) return translation$;
|
|
220
|
+
return combineLatest([translation$, this.showKeys$]).pipe(map(([value, showKeys]) => showKeys ? translationKey : value));
|
|
221
|
+
}
|
|
222
|
+
async configure() {
|
|
223
|
+
const language = this.checkFallbackLocalesMap(this.configuration.language || this.configuration.fallbackLanguage);
|
|
224
|
+
this.translateService.addLangs(this.configuration.supportedLocales);
|
|
225
|
+
this.translateService.setDefaultLang(language);
|
|
226
|
+
await firstValueFrom(this.useLanguage(language));
|
|
227
|
+
}
|
|
228
|
+
isTranslationDeactivationEnabled() {
|
|
229
|
+
return this.configuration.enableTranslationDeactivation;
|
|
230
|
+
}
|
|
231
|
+
getLanguages() {
|
|
232
|
+
return this.translateService.getLangs();
|
|
233
|
+
}
|
|
234
|
+
useLanguage(language) {
|
|
235
|
+
language = this.checkFallbackLocalesMap(language);
|
|
236
|
+
return this.translateService.use(language);
|
|
237
|
+
}
|
|
238
|
+
getCurrentLanguage() {
|
|
239
|
+
return this.translateService.currentLang;
|
|
240
|
+
}
|
|
241
|
+
getTranslateService() {
|
|
242
|
+
return this.translateService;
|
|
243
|
+
}
|
|
244
|
+
toggleShowKeys(value) {
|
|
245
|
+
if (!this.configuration.enableTranslationDeactivation) throw new Error("Translation deactivation is not enabled. Please set the LocalizationConfiguration property \"enableTranslationDeactivation\" accordingly.");
|
|
246
|
+
const newValue = value === void 0 ? !this.showKeys : value;
|
|
247
|
+
this._showKeys$.next(newValue);
|
|
248
|
+
}
|
|
249
|
+
get showKeys() {
|
|
250
|
+
return this._showKeys$.value;
|
|
251
|
+
}
|
|
252
|
+
getKey(requestedKey) {
|
|
253
|
+
return this.keyMapping$ ? this.keyMapping$.pipe(map((keyMapping) => keyMapping?.[requestedKey] || requestedKey), distinctUntilChanged()) : of(requestedKey);
|
|
254
|
+
}
|
|
255
|
+
translate(key, interpolateParams) {
|
|
256
|
+
return this.getKey(key).pipe(switchMap((translationKey) => this.getTranslationStream(translationKey, interpolateParams)), shareReplay({
|
|
257
|
+
refCount: true,
|
|
258
|
+
bufferSize: 1
|
|
259
|
+
}));
|
|
260
|
+
}
|
|
261
|
+
static {
|
|
262
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
263
|
+
minVersion: "12.0.0",
|
|
264
|
+
version: "22.2.3",
|
|
265
|
+
ngImport: i0,
|
|
266
|
+
type: LocalizationService,
|
|
267
|
+
deps: [],
|
|
268
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
static {
|
|
272
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
273
|
+
minVersion: "12.0.0",
|
|
274
|
+
version: "22.2.3",
|
|
275
|
+
ngImport: i0,
|
|
276
|
+
type: LocalizationService
|
|
277
|
+
});
|
|
278
|
+
}
|
|
191
279
|
};
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
}
|
|
581
|
-
transform(value, digitsInfo, locale) {
|
|
582
|
-
return super.transform(value, digitsInfo, locale || this.localizationService.getCurrentLanguage());
|
|
583
|
-
}
|
|
584
|
-
ngOnDestroy() {
|
|
585
|
-
this.onLangChange.unsubscribe();
|
|
586
|
-
}
|
|
587
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: LocalizedDecimalPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
588
|
-
/** @nocollapse */ static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "22.2.0", ngImport: i0, type: LocalizedDecimalPipe, isStandalone: false, name: "decimal", pure: false }); }
|
|
589
|
-
}
|
|
590
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: LocalizedDecimalPipe, decorators: [{
|
|
591
|
-
type: Pipe,
|
|
592
|
-
args: [{
|
|
593
|
-
name: 'decimal',
|
|
594
|
-
pure: false,
|
|
595
|
-
standalone: false
|
|
596
|
-
}]
|
|
597
|
-
}], ctorParameters: () => [] });
|
|
598
|
-
|
|
599
|
-
/**
|
|
600
|
-
* Service for handling the text direction based on the LocalizationConfiguration
|
|
601
|
-
*/
|
|
602
|
-
class TextDirectionService {
|
|
603
|
-
constructor() {
|
|
604
|
-
this.translateService = inject(TranslateService);
|
|
605
|
-
this.configuration = inject(LOCALIZATION_CONFIGURATION_TOKEN);
|
|
606
|
-
this.rendererFactory = inject(RendererFactory2);
|
|
607
|
-
this.directionality = inject(Directionality);
|
|
608
|
-
this.renderer = this.rendererFactory.createRenderer(null, null);
|
|
609
|
-
}
|
|
610
|
-
/**
|
|
611
|
-
* Updates the dir attribute on body HTML tag.
|
|
612
|
-
* @returns a subscription that updates the dir attribute
|
|
613
|
-
*/
|
|
614
|
-
onLangChangeSubscription() {
|
|
615
|
-
if (this.subscription && !this.subscription.closed) {
|
|
616
|
-
return this.subscription;
|
|
617
|
-
}
|
|
618
|
-
this.subscription = this.translateService.onLangChange.subscribe((event) => {
|
|
619
|
-
const direction = this.configuration.rtlLanguages.includes(event.lang.split('-')[0]) ? 'rtl' : 'ltr';
|
|
620
|
-
this.renderer.setAttribute(document.body, 'dir', direction);
|
|
621
|
-
this.directionality.change.emit(direction);
|
|
622
|
-
});
|
|
623
|
-
return this.subscription;
|
|
624
|
-
}
|
|
625
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: TextDirectionService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
626
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: TextDirectionService }); }
|
|
627
|
-
}
|
|
628
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: TextDirectionService, decorators: [{
|
|
629
|
-
type: Injectable
|
|
630
|
-
}], ctorParameters: () => [] });
|
|
631
|
-
|
|
632
|
-
/**
|
|
633
|
-
* @deprecated The value of Directionality is no longer readonly and can be updated, this class will be removed in v16
|
|
634
|
-
*/
|
|
635
|
-
class TextDirectionality extends Directionality {
|
|
636
|
-
get value() {
|
|
637
|
-
return this._value;
|
|
638
|
-
}
|
|
639
|
-
set value(value) {
|
|
640
|
-
this._value = value;
|
|
641
|
-
}
|
|
642
|
-
constructor() {
|
|
643
|
-
super();
|
|
644
|
-
/**
|
|
645
|
-
* The current 'ltr' or 'rtl' value.
|
|
646
|
-
* @override
|
|
647
|
-
*/
|
|
648
|
-
this._value = 'ltr';
|
|
649
|
-
this.change
|
|
650
|
-
.pipe(startWith(this._value))
|
|
651
|
-
.subscribe((value) => this._value = value);
|
|
652
|
-
}
|
|
653
|
-
ngOnDestroy() {
|
|
654
|
-
this.change.complete();
|
|
655
|
-
}
|
|
656
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: TextDirectionality, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
657
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: TextDirectionality }); }
|
|
658
|
-
}
|
|
659
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: TextDirectionality, decorators: [{
|
|
660
|
-
type: Injectable
|
|
661
|
-
}], ctorParameters: () => [] });
|
|
662
|
-
|
|
663
|
-
/**
|
|
664
|
-
* creates LocalizationConfiguration, which is used if the application
|
|
665
|
-
* @param configuration Localization configuration
|
|
666
|
-
*/
|
|
280
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
281
|
+
minVersion: "12.0.0",
|
|
282
|
+
version: "22.2.3",
|
|
283
|
+
ngImport: i0,
|
|
284
|
+
type: LocalizationService,
|
|
285
|
+
decorators: [{ type: Injectable }],
|
|
286
|
+
ctorParameters: () => []
|
|
287
|
+
});
|
|
288
|
+
var LocalizationTranslateDirective = class LocalizationTranslateDirective extends TranslateDirective {
|
|
289
|
+
set translate(key) {
|
|
290
|
+
if (key && key !== this.key) {
|
|
291
|
+
if (this.onKeyChange) this.onKeyChange.unsubscribe();
|
|
292
|
+
this.onKeyChange = this.localizationService.getKey(key).subscribe((newKey) => {
|
|
293
|
+
this.key = newKey;
|
|
294
|
+
this.checkNodes();
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
constructor() {
|
|
299
|
+
const translateService = inject(TranslateService);
|
|
300
|
+
const element = inject(ElementRef);
|
|
301
|
+
const ref = inject(ChangeDetectorRef);
|
|
302
|
+
super(translateService, element, ref);
|
|
303
|
+
this.localizationService = inject(LocalizationService);
|
|
304
|
+
this.localizationConfig = inject(LOCALIZATION_CONFIGURATION_TOKEN);
|
|
305
|
+
this.showKeys = false;
|
|
306
|
+
const localizationService = this.localizationService;
|
|
307
|
+
if (this.localizationConfig.enableTranslationDeactivation) this.onShowKeysChange = localizationService.showKeys$.subscribe((showKeys) => {
|
|
308
|
+
this.showKeys = showKeys;
|
|
309
|
+
this.checkNodes(true);
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
setContent(node, content) {
|
|
313
|
+
const key = node.originalContent;
|
|
314
|
+
const newContent = this.showKeys ? key : this.localizationConfig.debugMode && key ? `${key} - ${content}` : content;
|
|
315
|
+
if (typeof node.textContent !== "undefined" && node.textContent !== null) node.textContent = newContent;
|
|
316
|
+
else node.data = newContent;
|
|
317
|
+
}
|
|
318
|
+
ngOnDestroy() {
|
|
319
|
+
super.ngOnDestroy();
|
|
320
|
+
if (this.onShowKeysChange) this.onShowKeysChange.unsubscribe();
|
|
321
|
+
if (this.onKeyChange) this.onKeyChange?.unsubscribe();
|
|
322
|
+
}
|
|
323
|
+
static {
|
|
324
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
325
|
+
minVersion: "12.0.0",
|
|
326
|
+
version: "22.2.3",
|
|
327
|
+
ngImport: i0,
|
|
328
|
+
type: LocalizationTranslateDirective,
|
|
329
|
+
deps: [],
|
|
330
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
static {
|
|
334
|
+
this.ɵdir = i0.ɵɵngDeclareDirective({
|
|
335
|
+
minVersion: "14.0.0",
|
|
336
|
+
version: "22.2.3",
|
|
337
|
+
type: LocalizationTranslateDirective,
|
|
338
|
+
isStandalone: false,
|
|
339
|
+
selector: "[translate],[ngx-translate]",
|
|
340
|
+
inputs: { translate: "translate" },
|
|
341
|
+
usesInheritance: true,
|
|
342
|
+
ngImport: i0
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
347
|
+
minVersion: "12.0.0",
|
|
348
|
+
version: "22.2.3",
|
|
349
|
+
ngImport: i0,
|
|
350
|
+
type: LocalizationTranslateDirective,
|
|
351
|
+
decorators: [{
|
|
352
|
+
type: Directive,
|
|
353
|
+
args: [{
|
|
354
|
+
selector: "[translate],[ngx-translate]",
|
|
355
|
+
standalone: false
|
|
356
|
+
}]
|
|
357
|
+
}],
|
|
358
|
+
ctorParameters: () => [],
|
|
359
|
+
propDecorators: { translate: [{ type: Input }] }
|
|
360
|
+
});
|
|
361
|
+
var O3rLocalizationTranslatePipe = class O3rLocalizationTranslatePipe extends TranslatePipe {
|
|
362
|
+
constructor() {
|
|
363
|
+
super(inject(TranslateService), inject(ChangeDetectorRef));
|
|
364
|
+
this.localizationService = inject(LocalizationService);
|
|
365
|
+
this.changeDetector = inject(ChangeDetectorRef);
|
|
366
|
+
this.localizationConfig = inject(LOCALIZATION_CONFIGURATION_TOKEN);
|
|
367
|
+
this.showKeys = false;
|
|
368
|
+
if (this.localizationConfig.enableTranslationDeactivation) this.onShowKeysChange = this.localizationService.showKeys$.subscribe((showKeys) => {
|
|
369
|
+
this.showKeys = showKeys;
|
|
370
|
+
this.changeDetector.markForCheck();
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
transform(query, ...args) {
|
|
374
|
+
if (this.showKeys) return query;
|
|
375
|
+
if (query !== this.lastQueryKey) {
|
|
376
|
+
this.lastQueryKey = query;
|
|
377
|
+
if (this.onKeyChange) this.onKeyChange.unsubscribe();
|
|
378
|
+
this.onKeyChange = this.localizationService.getKey(query).subscribe((key) => {
|
|
379
|
+
this.lastResolvedKey = key;
|
|
380
|
+
this.changeDetector.markForCheck();
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
if (this.lastResolvedKey) {
|
|
384
|
+
const value = super.transform(this.lastResolvedKey, ...args);
|
|
385
|
+
if (this.localizationConfig.debugMode) return `${this.lastResolvedKey} - ${value}`;
|
|
386
|
+
return value;
|
|
387
|
+
}
|
|
388
|
+
return this.value;
|
|
389
|
+
}
|
|
390
|
+
ngOnDestroy() {
|
|
391
|
+
super.ngOnDestroy();
|
|
392
|
+
if (this.onShowKeysChange) this.onShowKeysChange.unsubscribe();
|
|
393
|
+
if (this.onKeyChange) this.onKeyChange.unsubscribe();
|
|
394
|
+
}
|
|
395
|
+
static {
|
|
396
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
397
|
+
minVersion: "12.0.0",
|
|
398
|
+
version: "22.2.3",
|
|
399
|
+
ngImport: i0,
|
|
400
|
+
type: O3rLocalizationTranslatePipe,
|
|
401
|
+
deps: [],
|
|
402
|
+
target: i0.ɵɵFactoryTarget.Pipe
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
static {
|
|
406
|
+
this.ɵpipe = i0.ɵɵngDeclarePipe({
|
|
407
|
+
minVersion: "14.0.0",
|
|
408
|
+
version: "22.2.3",
|
|
409
|
+
ngImport: i0,
|
|
410
|
+
type: O3rLocalizationTranslatePipe,
|
|
411
|
+
isStandalone: false,
|
|
412
|
+
name: "o3rTranslate",
|
|
413
|
+
pure: false
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
418
|
+
minVersion: "12.0.0",
|
|
419
|
+
version: "22.2.3",
|
|
420
|
+
ngImport: i0,
|
|
421
|
+
type: O3rLocalizationTranslatePipe,
|
|
422
|
+
decorators: [{
|
|
423
|
+
type: Pipe,
|
|
424
|
+
args: [{
|
|
425
|
+
name: "o3rTranslate",
|
|
426
|
+
pure: false,
|
|
427
|
+
standalone: false
|
|
428
|
+
}]
|
|
429
|
+
}],
|
|
430
|
+
ctorParameters: () => []
|
|
431
|
+
});
|
|
432
|
+
var LocalizedCurrencyPipe = class LocalizedCurrencyPipe extends CurrencyPipe {
|
|
433
|
+
constructor() {
|
|
434
|
+
super(inject(LocalizationService).getCurrentLanguage());
|
|
435
|
+
this.localizationService = inject(LocalizationService);
|
|
436
|
+
this.changeDetectorRef = inject(ChangeDetectorRef);
|
|
437
|
+
this.onLangChange = this.localizationService.getTranslateService().onLangChange.subscribe(() => this.changeDetectorRef.markForCheck());
|
|
438
|
+
}
|
|
439
|
+
transform(value, currencyCode, display, digitsInfo, locale) {
|
|
440
|
+
return super.transform(value, currencyCode, display, digitsInfo, locale || this.localizationService.getCurrentLanguage());
|
|
441
|
+
}
|
|
442
|
+
ngOnDestroy() {
|
|
443
|
+
this.onLangChange.unsubscribe();
|
|
444
|
+
}
|
|
445
|
+
static {
|
|
446
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
447
|
+
minVersion: "12.0.0",
|
|
448
|
+
version: "22.2.3",
|
|
449
|
+
ngImport: i0,
|
|
450
|
+
type: LocalizedCurrencyPipe,
|
|
451
|
+
deps: [],
|
|
452
|
+
target: i0.ɵɵFactoryTarget.Pipe
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
static {
|
|
456
|
+
this.ɵpipe = i0.ɵɵngDeclarePipe({
|
|
457
|
+
minVersion: "14.0.0",
|
|
458
|
+
version: "22.2.3",
|
|
459
|
+
ngImport: i0,
|
|
460
|
+
type: LocalizedCurrencyPipe,
|
|
461
|
+
isStandalone: false,
|
|
462
|
+
name: "currency",
|
|
463
|
+
pure: false
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
};
|
|
467
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
468
|
+
minVersion: "12.0.0",
|
|
469
|
+
version: "22.2.3",
|
|
470
|
+
ngImport: i0,
|
|
471
|
+
type: LocalizedCurrencyPipe,
|
|
472
|
+
decorators: [{
|
|
473
|
+
type: Pipe,
|
|
474
|
+
args: [{
|
|
475
|
+
name: "currency",
|
|
476
|
+
pure: false,
|
|
477
|
+
standalone: false
|
|
478
|
+
}]
|
|
479
|
+
}],
|
|
480
|
+
ctorParameters: () => []
|
|
481
|
+
});
|
|
482
|
+
var LocalizedDatePipe = class LocalizedDatePipe extends DatePipe {
|
|
483
|
+
constructor() {
|
|
484
|
+
super(inject(LocalizationService).getCurrentLanguage());
|
|
485
|
+
this.localizationService = inject(LocalizationService);
|
|
486
|
+
this.changeDetectorRef = inject(ChangeDetectorRef);
|
|
487
|
+
this.onLangChange = this.localizationService.getTranslateService().onLangChange.subscribe(() => this.changeDetectorRef.markForCheck());
|
|
488
|
+
}
|
|
489
|
+
transform(value, format = "mediumDate", timezone, locale) {
|
|
490
|
+
return this.localizationService.showKeys ? format : super.transform(value, format, timezone, locale || this.localizationService.getCurrentLanguage());
|
|
491
|
+
}
|
|
492
|
+
ngOnDestroy() {
|
|
493
|
+
this.onLangChange.unsubscribe();
|
|
494
|
+
}
|
|
495
|
+
static {
|
|
496
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
497
|
+
minVersion: "12.0.0",
|
|
498
|
+
version: "22.2.3",
|
|
499
|
+
ngImport: i0,
|
|
500
|
+
type: LocalizedDatePipe,
|
|
501
|
+
deps: [],
|
|
502
|
+
target: i0.ɵɵFactoryTarget.Pipe
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
static {
|
|
506
|
+
this.ɵpipe = i0.ɵɵngDeclarePipe({
|
|
507
|
+
minVersion: "14.0.0",
|
|
508
|
+
version: "22.2.3",
|
|
509
|
+
ngImport: i0,
|
|
510
|
+
type: LocalizedDatePipe,
|
|
511
|
+
isStandalone: false,
|
|
512
|
+
name: "date",
|
|
513
|
+
pure: false
|
|
514
|
+
});
|
|
515
|
+
}
|
|
516
|
+
};
|
|
517
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
518
|
+
minVersion: "12.0.0",
|
|
519
|
+
version: "22.2.3",
|
|
520
|
+
ngImport: i0,
|
|
521
|
+
type: LocalizedDatePipe,
|
|
522
|
+
decorators: [{
|
|
523
|
+
type: Pipe,
|
|
524
|
+
args: [{
|
|
525
|
+
name: "date",
|
|
526
|
+
pure: false,
|
|
527
|
+
standalone: false
|
|
528
|
+
}]
|
|
529
|
+
}],
|
|
530
|
+
ctorParameters: () => []
|
|
531
|
+
});
|
|
532
|
+
var LocalizedDecimalPipe = class LocalizedDecimalPipe extends DecimalPipe {
|
|
533
|
+
constructor() {
|
|
534
|
+
super(inject(LocalizationService).getCurrentLanguage());
|
|
535
|
+
this.localizationService = inject(LocalizationService);
|
|
536
|
+
this.changeDetectorRef = inject(ChangeDetectorRef);
|
|
537
|
+
this.onLangChange = this.localizationService.getTranslateService().onLangChange.subscribe(() => this.changeDetectorRef.markForCheck());
|
|
538
|
+
}
|
|
539
|
+
transform(value, digitsInfo, locale) {
|
|
540
|
+
return super.transform(value, digitsInfo, locale || this.localizationService.getCurrentLanguage());
|
|
541
|
+
}
|
|
542
|
+
ngOnDestroy() {
|
|
543
|
+
this.onLangChange.unsubscribe();
|
|
544
|
+
}
|
|
545
|
+
static {
|
|
546
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
547
|
+
minVersion: "12.0.0",
|
|
548
|
+
version: "22.2.3",
|
|
549
|
+
ngImport: i0,
|
|
550
|
+
type: LocalizedDecimalPipe,
|
|
551
|
+
deps: [],
|
|
552
|
+
target: i0.ɵɵFactoryTarget.Pipe
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
static {
|
|
556
|
+
this.ɵpipe = i0.ɵɵngDeclarePipe({
|
|
557
|
+
minVersion: "14.0.0",
|
|
558
|
+
version: "22.2.3",
|
|
559
|
+
ngImport: i0,
|
|
560
|
+
type: LocalizedDecimalPipe,
|
|
561
|
+
isStandalone: false,
|
|
562
|
+
name: "decimal",
|
|
563
|
+
pure: false
|
|
564
|
+
});
|
|
565
|
+
}
|
|
566
|
+
};
|
|
567
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
568
|
+
minVersion: "12.0.0",
|
|
569
|
+
version: "22.2.3",
|
|
570
|
+
ngImport: i0,
|
|
571
|
+
type: LocalizedDecimalPipe,
|
|
572
|
+
decorators: [{
|
|
573
|
+
type: Pipe,
|
|
574
|
+
args: [{
|
|
575
|
+
name: "decimal",
|
|
576
|
+
pure: false,
|
|
577
|
+
standalone: false
|
|
578
|
+
}]
|
|
579
|
+
}],
|
|
580
|
+
ctorParameters: () => []
|
|
581
|
+
});
|
|
582
|
+
var TextDirectionService = class TextDirectionService {
|
|
583
|
+
constructor() {
|
|
584
|
+
this.translateService = inject(TranslateService);
|
|
585
|
+
this.configuration = inject(LOCALIZATION_CONFIGURATION_TOKEN);
|
|
586
|
+
this.rendererFactory = inject(RendererFactory2);
|
|
587
|
+
this.directionality = inject(Directionality);
|
|
588
|
+
this.renderer = this.rendererFactory.createRenderer(null, null);
|
|
589
|
+
}
|
|
590
|
+
onLangChangeSubscription() {
|
|
591
|
+
if (this.subscription && !this.subscription.closed) return this.subscription;
|
|
592
|
+
this.subscription = this.translateService.onLangChange.subscribe((event) => {
|
|
593
|
+
const direction = this.configuration.rtlLanguages.includes(event.lang.split("-")[0]) ? "rtl" : "ltr";
|
|
594
|
+
this.renderer.setAttribute(document.body, "dir", direction);
|
|
595
|
+
this.directionality.change.emit(direction);
|
|
596
|
+
});
|
|
597
|
+
return this.subscription;
|
|
598
|
+
}
|
|
599
|
+
static {
|
|
600
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
601
|
+
minVersion: "12.0.0",
|
|
602
|
+
version: "22.2.3",
|
|
603
|
+
ngImport: i0,
|
|
604
|
+
type: TextDirectionService,
|
|
605
|
+
deps: [],
|
|
606
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
static {
|
|
610
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
611
|
+
minVersion: "12.0.0",
|
|
612
|
+
version: "22.2.3",
|
|
613
|
+
ngImport: i0,
|
|
614
|
+
type: TextDirectionService
|
|
615
|
+
});
|
|
616
|
+
}
|
|
617
|
+
};
|
|
618
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
619
|
+
minVersion: "12.0.0",
|
|
620
|
+
version: "22.2.3",
|
|
621
|
+
ngImport: i0,
|
|
622
|
+
type: TextDirectionService,
|
|
623
|
+
decorators: [{ type: Injectable }],
|
|
624
|
+
ctorParameters: () => []
|
|
625
|
+
});
|
|
626
|
+
var TextDirectionality = class TextDirectionality extends Directionality {
|
|
627
|
+
get value() {
|
|
628
|
+
return this._value;
|
|
629
|
+
}
|
|
630
|
+
set value(value) {
|
|
631
|
+
this._value = value;
|
|
632
|
+
}
|
|
633
|
+
constructor() {
|
|
634
|
+
super();
|
|
635
|
+
this._value = "ltr";
|
|
636
|
+
this.change.pipe(startWith(this._value)).subscribe((value) => this._value = value);
|
|
637
|
+
}
|
|
638
|
+
ngOnDestroy() {
|
|
639
|
+
this.change.complete();
|
|
640
|
+
}
|
|
641
|
+
static {
|
|
642
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
643
|
+
minVersion: "12.0.0",
|
|
644
|
+
version: "22.2.3",
|
|
645
|
+
ngImport: i0,
|
|
646
|
+
type: TextDirectionality,
|
|
647
|
+
deps: [],
|
|
648
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
static {
|
|
652
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
653
|
+
minVersion: "12.0.0",
|
|
654
|
+
version: "22.2.3",
|
|
655
|
+
ngImport: i0,
|
|
656
|
+
type: TextDirectionality
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
};
|
|
660
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
661
|
+
minVersion: "12.0.0",
|
|
662
|
+
version: "22.2.3",
|
|
663
|
+
ngImport: i0,
|
|
664
|
+
type: TextDirectionality,
|
|
665
|
+
decorators: [{ type: Injectable }],
|
|
666
|
+
ctorParameters: () => []
|
|
667
|
+
});
|
|
667
668
|
function createLocalizationConfiguration(configuration) {
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
669
|
+
return {
|
|
670
|
+
...DEFAULT_LOCALIZATION_CONFIGURATION,
|
|
671
|
+
...configuration
|
|
672
|
+
};
|
|
672
673
|
}
|
|
673
|
-
/**
|
|
674
|
-
* Factory to inject the LOCALE_ID token with the current language into Angular context
|
|
675
|
-
* @param localizationService Localization service
|
|
676
|
-
*/
|
|
677
674
|
function localeIdNgBridge(localizationService) {
|
|
678
|
-
|
|
675
|
+
return localizationService.getCurrentLanguage();
|
|
679
676
|
}
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
}
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
677
|
+
const CUSTOM_LOCALIZATION_CONFIGURATION_TOKEN = new InjectionToken("Partial Localization configuration");
|
|
678
|
+
var LocalizationModule = class LocalizationModule {
|
|
679
|
+
static forRoot(configuration) {
|
|
680
|
+
return {
|
|
681
|
+
ngModule: LocalizationModule,
|
|
682
|
+
providers: [LocalizationService, ...configuration ? [{
|
|
683
|
+
provide: CUSTOM_LOCALIZATION_CONFIGURATION_TOKEN,
|
|
684
|
+
useFactory: configuration
|
|
685
|
+
}] : []]
|
|
686
|
+
};
|
|
687
|
+
}
|
|
688
|
+
static {
|
|
689
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
690
|
+
minVersion: "12.0.0",
|
|
691
|
+
version: "22.2.3",
|
|
692
|
+
ngImport: i0,
|
|
693
|
+
type: LocalizationModule,
|
|
694
|
+
deps: [],
|
|
695
|
+
target: i0.ɵɵFactoryTarget.NgModule
|
|
696
|
+
});
|
|
697
|
+
}
|
|
698
|
+
static {
|
|
699
|
+
this.ɵmod = i0.ɵɵngDeclareNgModule({
|
|
700
|
+
minVersion: "14.0.0",
|
|
701
|
+
version: "22.2.3",
|
|
702
|
+
ngImport: i0,
|
|
703
|
+
type: LocalizationModule,
|
|
704
|
+
declarations: [
|
|
705
|
+
O3rLocalizationTranslatePipe,
|
|
706
|
+
LocalizationTranslateDirective,
|
|
707
|
+
LocalizedDatePipe,
|
|
708
|
+
LocalizedDecimalPipe,
|
|
709
|
+
LocalizedCurrencyPipe
|
|
710
|
+
],
|
|
711
|
+
imports: [
|
|
712
|
+
TranslateModule,
|
|
713
|
+
BidiModule,
|
|
714
|
+
CommonModule
|
|
715
|
+
],
|
|
716
|
+
exports: [
|
|
717
|
+
TranslateModule,
|
|
718
|
+
O3rLocalizationTranslatePipe,
|
|
719
|
+
LocalizationTranslateDirective,
|
|
720
|
+
LocalizedDatePipe,
|
|
721
|
+
LocalizedDecimalPipe,
|
|
722
|
+
LocalizedCurrencyPipe
|
|
723
|
+
]
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
static {
|
|
727
|
+
this.ɵinj = i0.ɵɵngDeclareInjector({
|
|
728
|
+
minVersion: "12.0.0",
|
|
729
|
+
version: "22.2.3",
|
|
730
|
+
ngImport: i0,
|
|
731
|
+
type: LocalizationModule,
|
|
732
|
+
providers: [
|
|
733
|
+
{
|
|
734
|
+
provide: LOCALIZATION_CONFIGURATION_TOKEN,
|
|
735
|
+
useFactory: createLocalizationConfiguration,
|
|
736
|
+
deps: [[new Optional(), CUSTOM_LOCALIZATION_CONFIGURATION_TOKEN]]
|
|
737
|
+
},
|
|
738
|
+
{
|
|
739
|
+
provide: LOCALE_ID,
|
|
740
|
+
useFactory: localeIdNgBridge,
|
|
741
|
+
deps: [LocalizationService]
|
|
742
|
+
},
|
|
743
|
+
{
|
|
744
|
+
provide: Directionality,
|
|
745
|
+
useClass: TextDirectionality
|
|
746
|
+
},
|
|
747
|
+
{
|
|
748
|
+
provide: DatePipe,
|
|
749
|
+
useClass: LocalizedDatePipe
|
|
750
|
+
},
|
|
751
|
+
{
|
|
752
|
+
provide: DecimalPipe,
|
|
753
|
+
useClass: LocalizedDecimalPipe
|
|
754
|
+
},
|
|
755
|
+
{
|
|
756
|
+
provide: CurrencyPipe,
|
|
757
|
+
useClass: LocalizedCurrencyPipe
|
|
758
|
+
},
|
|
759
|
+
TextDirectionService
|
|
760
|
+
],
|
|
761
|
+
imports: [
|
|
762
|
+
TranslateModule,
|
|
763
|
+
BidiModule,
|
|
764
|
+
CommonModule,
|
|
765
|
+
TranslateModule
|
|
766
|
+
]
|
|
767
|
+
});
|
|
768
|
+
}
|
|
769
|
+
};
|
|
770
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
771
|
+
minVersion: "12.0.0",
|
|
772
|
+
version: "22.2.3",
|
|
773
|
+
ngImport: i0,
|
|
774
|
+
type: LocalizationModule,
|
|
775
|
+
decorators: [{
|
|
776
|
+
type: NgModule,
|
|
777
|
+
args: [{
|
|
778
|
+
declarations: [
|
|
779
|
+
O3rLocalizationTranslatePipe,
|
|
780
|
+
LocalizationTranslateDirective,
|
|
781
|
+
LocalizedDatePipe,
|
|
782
|
+
LocalizedDecimalPipe,
|
|
783
|
+
LocalizedCurrencyPipe
|
|
784
|
+
],
|
|
785
|
+
imports: [
|
|
786
|
+
TranslateModule,
|
|
787
|
+
BidiModule,
|
|
788
|
+
CommonModule
|
|
789
|
+
],
|
|
790
|
+
exports: [
|
|
791
|
+
TranslateModule,
|
|
792
|
+
O3rLocalizationTranslatePipe,
|
|
793
|
+
LocalizationTranslateDirective,
|
|
794
|
+
LocalizedDatePipe,
|
|
795
|
+
LocalizedDecimalPipe,
|
|
796
|
+
LocalizedCurrencyPipe
|
|
797
|
+
],
|
|
798
|
+
providers: [
|
|
799
|
+
{
|
|
800
|
+
provide: LOCALIZATION_CONFIGURATION_TOKEN,
|
|
801
|
+
useFactory: createLocalizationConfiguration,
|
|
802
|
+
deps: [[new Optional(), CUSTOM_LOCALIZATION_CONFIGURATION_TOKEN]]
|
|
803
|
+
},
|
|
804
|
+
{
|
|
805
|
+
provide: LOCALE_ID,
|
|
806
|
+
useFactory: localeIdNgBridge,
|
|
807
|
+
deps: [LocalizationService]
|
|
808
|
+
},
|
|
809
|
+
{
|
|
810
|
+
provide: Directionality,
|
|
811
|
+
useClass: TextDirectionality
|
|
812
|
+
},
|
|
813
|
+
{
|
|
814
|
+
provide: DatePipe,
|
|
815
|
+
useClass: LocalizedDatePipe
|
|
816
|
+
},
|
|
817
|
+
{
|
|
818
|
+
provide: DecimalPipe,
|
|
819
|
+
useClass: LocalizedDecimalPipe
|
|
820
|
+
},
|
|
821
|
+
{
|
|
822
|
+
provide: CurrencyPipe,
|
|
823
|
+
useClass: LocalizedCurrencyPipe
|
|
824
|
+
},
|
|
825
|
+
TextDirectionService
|
|
826
|
+
]
|
|
827
|
+
}]
|
|
828
|
+
}]
|
|
829
|
+
});
|
|
830
|
+
const JSON_EXT = ".json";
|
|
831
|
+
var TranslationsLoader = class TranslationsLoader {
|
|
832
|
+
constructor() {
|
|
833
|
+
this.localizationConfiguration = inject(LOCALIZATION_CONFIGURATION_TOKEN);
|
|
834
|
+
this.logger = inject(LoggerService, { optional: true });
|
|
835
|
+
this.dynamicContentService = inject(DynamicContentService, { optional: true });
|
|
836
|
+
}
|
|
837
|
+
downloadLanguageBundle$(url) {
|
|
838
|
+
const queryParams = this.localizationConfiguration.queryParams;
|
|
839
|
+
let queryString = "";
|
|
840
|
+
if (queryParams) queryString = "?" + Object.keys(queryParams).map((key) => encodeURIComponent(key) + "=" + encodeURIComponent(queryParams[key])).join("&");
|
|
841
|
+
return from(fetch(url + queryString, this.localizationConfiguration.fetchOptions)).pipe(switchMap((response) => from(response.json())));
|
|
842
|
+
}
|
|
843
|
+
getTranslation(lang) {
|
|
844
|
+
const fallback = this.localizationConfiguration.fallbackLanguage;
|
|
845
|
+
let localizationPath$ = of(this.localizationConfiguration.endPointUrl);
|
|
846
|
+
if (this.localizationConfiguration.useDynamicContent) {
|
|
847
|
+
if (!this.dynamicContentService) throw new Error("Dynamic Content is not available. Please verify you have provided the DynamicContent in your application");
|
|
848
|
+
localizationPath$ = this.dynamicContentService.getContentPathStream(this.localizationConfiguration.endPointUrl);
|
|
849
|
+
}
|
|
850
|
+
return localizationPath$.pipe(switchMap((localizationPath) => {
|
|
851
|
+
if (localizationPath) {
|
|
852
|
+
const localizationBundle$ = this.downloadLanguageBundle$(localizationPath + lang + JSON_EXT);
|
|
853
|
+
if (this.localizationConfiguration.mergeWithLocalTranslations) return combineLatest([localizationBundle$.pipe(catchError(() => of({}))), this.getTranslationFromLocal(lang, fallback).pipe(map((translations) => {
|
|
854
|
+
Object.keys(translations).forEach((key) => translations[key] = `[local] ${translations[key]}`);
|
|
855
|
+
return translations;
|
|
856
|
+
}))]).pipe(map(([dynamicTranslations, localTranslations]) => ({
|
|
857
|
+
...localTranslations,
|
|
858
|
+
...dynamicTranslations
|
|
859
|
+
})));
|
|
860
|
+
return localizationBundle$.pipe(catchError(() => {
|
|
861
|
+
this.logger?.warn(`Failed to load the localization resource from ${localizationPath + lang + JSON_EXT}, trying from the application resources`);
|
|
862
|
+
return this.getTranslationFromLocal(lang, fallback);
|
|
863
|
+
}));
|
|
864
|
+
}
|
|
865
|
+
this.logger?.warn("No localization endpoint specified, localization fetch from application resources");
|
|
866
|
+
return this.getTranslationFromLocal(lang, fallback);
|
|
867
|
+
}));
|
|
868
|
+
}
|
|
869
|
+
getTranslationFromLocal(lang, fallbackLanguage) {
|
|
870
|
+
const pathPrefix = this.localizationConfiguration.bundlesOutputPath;
|
|
871
|
+
return this.downloadLanguageBundle$(pathPrefix + lang + JSON_EXT).pipe(catchError(() => {
|
|
872
|
+
if (lang === fallbackLanguage) {
|
|
873
|
+
this.logger?.warn(`Failed to load ${lang} from ${pathPrefix + lang + JSON_EXT}.`);
|
|
874
|
+
return of({});
|
|
875
|
+
} else {
|
|
876
|
+
this.logger?.warn(`Failed to load ${lang} from ${pathPrefix + lang + JSON_EXT}. Application will fallback to ${fallbackLanguage}`);
|
|
877
|
+
return this.downloadLanguageBundle$(pathPrefix + fallbackLanguage + JSON_EXT).pipe(catchError(() => of({})));
|
|
878
|
+
}
|
|
879
|
+
}));
|
|
880
|
+
}
|
|
881
|
+
static {
|
|
882
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
883
|
+
minVersion: "12.0.0",
|
|
884
|
+
version: "22.2.3",
|
|
885
|
+
ngImport: i0,
|
|
886
|
+
type: TranslationsLoader,
|
|
887
|
+
deps: [],
|
|
888
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
889
|
+
});
|
|
890
|
+
}
|
|
891
|
+
static {
|
|
892
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
893
|
+
minVersion: "12.0.0",
|
|
894
|
+
version: "22.2.3",
|
|
895
|
+
ngImport: i0,
|
|
896
|
+
type: TranslationsLoader
|
|
897
|
+
});
|
|
898
|
+
}
|
|
899
|
+
};
|
|
900
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
901
|
+
minVersion: "12.0.0",
|
|
902
|
+
version: "22.2.3",
|
|
903
|
+
ngImport: i0,
|
|
904
|
+
type: TranslationsLoader,
|
|
905
|
+
decorators: [{ type: Injectable }]
|
|
906
|
+
});
|
|
839
907
|
function createTranslateLoader(localizationConfiguration, logger, dynamicContentService) {
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
908
|
+
return Injector.create({ providers: [
|
|
909
|
+
{
|
|
910
|
+
provide: LOCALIZATION_CONFIGURATION_TOKEN,
|
|
911
|
+
useValue: localizationConfiguration
|
|
912
|
+
},
|
|
913
|
+
{
|
|
914
|
+
provide: LoggerService,
|
|
915
|
+
useValue: logger
|
|
916
|
+
},
|
|
917
|
+
{
|
|
918
|
+
provide: DynamicContentService,
|
|
919
|
+
useValue: dynamicContentService
|
|
920
|
+
},
|
|
921
|
+
{
|
|
922
|
+
provide: TranslationsLoader,
|
|
923
|
+
deps: [
|
|
924
|
+
[LoggerService, new Optional()],
|
|
925
|
+
[DynamicContentService, new Optional()],
|
|
926
|
+
LOCALIZATION_CONFIGURATION_TOKEN
|
|
927
|
+
]
|
|
928
|
+
}
|
|
929
|
+
] }).get(TranslationsLoader);
|
|
852
930
|
}
|
|
853
|
-
/**
|
|
854
|
-
* TranslateLoader provider, using framework's TranslationsLoader class
|
|
855
|
-
*/
|
|
856
931
|
const translateLoaderProvider = {
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
932
|
+
provide: TranslateLoader,
|
|
933
|
+
useFactory: createTranslateLoader,
|
|
934
|
+
deps: [
|
|
935
|
+
LOCALIZATION_CONFIGURATION_TOKEN,
|
|
936
|
+
[new Optional(), LoggerService],
|
|
937
|
+
[new Optional(), DynamicContentService]
|
|
938
|
+
]
|
|
860
939
|
};
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
* @see https://github.com/ngx-translate/core/blob/master/packages/core/lib/translate.service.ts#L490
|
|
929
|
-
* @param language language to reload
|
|
930
|
-
*/
|
|
931
|
-
async reloadLocalizationKeys(language) {
|
|
932
|
-
const lang = language || this.getCurrentLanguage();
|
|
933
|
-
if (this.translateCompiler.clearCache) {
|
|
934
|
-
this.translateCompiler.clearCache();
|
|
935
|
-
}
|
|
936
|
-
const initialLocs = await lastValueFrom(this.localizationService
|
|
937
|
-
.getTranslateService()
|
|
938
|
-
.reloadLang(lang));
|
|
939
|
-
this.localizationService.getTranslateService().setTranslation(language || this.getCurrentLanguage(), initialLocs);
|
|
940
|
-
this.appRef.tick();
|
|
941
|
-
}
|
|
942
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: OtterLocalizationDevtools, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
943
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: OtterLocalizationDevtools }); }
|
|
944
|
-
}
|
|
945
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: OtterLocalizationDevtools, decorators: [{
|
|
946
|
-
type: Injectable
|
|
947
|
-
}] });
|
|
948
|
-
|
|
940
|
+
var OtterLocalizationDevtools = class OtterLocalizationDevtools {
|
|
941
|
+
constructor() {
|
|
942
|
+
this.localizationService = inject(LocalizationService);
|
|
943
|
+
this.translateCompiler = inject(TranslateCompiler);
|
|
944
|
+
this.appRef = inject(ApplicationRef);
|
|
945
|
+
}
|
|
946
|
+
isTranslationDeactivationEnabled() {
|
|
947
|
+
return this.localizationService.isTranslationDeactivationEnabled();
|
|
948
|
+
}
|
|
949
|
+
showLocalizationKeys(value) {
|
|
950
|
+
this.localizationService.toggleShowKeys(value);
|
|
951
|
+
this.appRef.tick();
|
|
952
|
+
}
|
|
953
|
+
getCurrentLanguage() {
|
|
954
|
+
return this.localizationService.getCurrentLanguage();
|
|
955
|
+
}
|
|
956
|
+
onLanguageChange(fn) {
|
|
957
|
+
return this.localizationService.getTranslateService().onLangChange.subscribe(({ lang }) => {
|
|
958
|
+
fn(lang);
|
|
959
|
+
});
|
|
960
|
+
}
|
|
961
|
+
async switchLanguage(language) {
|
|
962
|
+
if (!language) return;
|
|
963
|
+
await lastValueFrom(this.localizationService.useLanguage(language));
|
|
964
|
+
this.appRef.tick();
|
|
965
|
+
}
|
|
966
|
+
updateLocalizationKeys(keyValues, language) {
|
|
967
|
+
const lang = language || this.getCurrentLanguage();
|
|
968
|
+
const translateService = this.localizationService.getTranslateService();
|
|
969
|
+
Object.entries(keyValues).forEach(([key, value]) => {
|
|
970
|
+
translateService.set(key, value, lang);
|
|
971
|
+
});
|
|
972
|
+
this.appRef.tick();
|
|
973
|
+
}
|
|
974
|
+
async reloadLocalizationKeys(language) {
|
|
975
|
+
const lang = language || this.getCurrentLanguage();
|
|
976
|
+
if (this.translateCompiler.clearCache) this.translateCompiler.clearCache();
|
|
977
|
+
const initialLocs = await lastValueFrom(this.localizationService.getTranslateService().reloadLang(lang));
|
|
978
|
+
this.localizationService.getTranslateService().setTranslation(language || this.getCurrentLanguage(), initialLocs);
|
|
979
|
+
this.appRef.tick();
|
|
980
|
+
}
|
|
981
|
+
static {
|
|
982
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
983
|
+
minVersion: "12.0.0",
|
|
984
|
+
version: "22.2.3",
|
|
985
|
+
ngImport: i0,
|
|
986
|
+
type: OtterLocalizationDevtools,
|
|
987
|
+
deps: [],
|
|
988
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
989
|
+
});
|
|
990
|
+
}
|
|
991
|
+
static {
|
|
992
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
993
|
+
minVersion: "12.0.0",
|
|
994
|
+
version: "22.2.3",
|
|
995
|
+
ngImport: i0,
|
|
996
|
+
type: OtterLocalizationDevtools
|
|
997
|
+
});
|
|
998
|
+
}
|
|
999
|
+
};
|
|
1000
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1001
|
+
minVersion: "12.0.0",
|
|
1002
|
+
version: "22.2.3",
|
|
1003
|
+
ngImport: i0,
|
|
1004
|
+
type: OtterLocalizationDevtools,
|
|
1005
|
+
decorators: [{ type: Injectable }]
|
|
1006
|
+
});
|
|
949
1007
|
const OTTER_LOCALIZATION_DEVTOOLS_DEFAULT_OPTIONS = {
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
1008
|
+
isActivatedOnBootstrap: false,
|
|
1009
|
+
isActivatedOnBootstrapWhenCMSContext: true,
|
|
1010
|
+
metadataFilePath: "./metadata/localisation.metadata.json"
|
|
953
1011
|
};
|
|
954
|
-
const OTTER_LOCALIZATION_DEVTOOLS_OPTIONS = new InjectionToken(
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
return this.localizationDevtools.reloadLocalizationKeys(language);
|
|
1025
|
-
}
|
|
1026
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: LocalizationDevtoolsConsoleService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1027
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: LocalizationDevtoolsConsoleService }); }
|
|
1028
|
-
}
|
|
1029
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: LocalizationDevtoolsConsoleService, decorators: [{
|
|
1030
|
-
type: Injectable
|
|
1031
|
-
}], ctorParameters: () => [] });
|
|
1032
|
-
|
|
1012
|
+
const OTTER_LOCALIZATION_DEVTOOLS_OPTIONS = new InjectionToken("Otter Localization Devtools options");
|
|
1013
|
+
var LocalizationDevtoolsConsoleService = class LocalizationDevtoolsConsoleService {
|
|
1014
|
+
static {
|
|
1015
|
+
this.windowModuleName = "localization";
|
|
1016
|
+
}
|
|
1017
|
+
constructor() {
|
|
1018
|
+
this.localizationDevtools = inject(OtterLocalizationDevtools);
|
|
1019
|
+
this.options = inject(OTTER_LOCALIZATION_DEVTOOLS_OPTIONS, { optional: true }) ?? OTTER_LOCALIZATION_DEVTOOLS_DEFAULT_OPTIONS;
|
|
1020
|
+
if (this.options.isActivatedOnBootstrap || this.options.isActivatedOnBootstrapWhenCMSContext && document.body.dataset.cmscontext === "true") this.activate();
|
|
1021
|
+
}
|
|
1022
|
+
activate() {
|
|
1023
|
+
const windowWithDevtools = window;
|
|
1024
|
+
windowWithDevtools._OTTER_DEVTOOLS_ ||= {};
|
|
1025
|
+
windowWithDevtools._OTTER_DEVTOOLS_[LocalizationDevtoolsConsoleService.windowModuleName] = this;
|
|
1026
|
+
console.info(`Otter localization Devtools is now accessible via the _OTTER_DEVTOOLS_.${LocalizationDevtoolsConsoleService.windowModuleName} variable`);
|
|
1027
|
+
}
|
|
1028
|
+
isTranslationDeactivationEnabled() {
|
|
1029
|
+
return this.localizationDevtools.isTranslationDeactivationEnabled();
|
|
1030
|
+
}
|
|
1031
|
+
showLocalizationKeys(value) {
|
|
1032
|
+
this.localizationDevtools.showLocalizationKeys(value);
|
|
1033
|
+
}
|
|
1034
|
+
getCurrentLanguage() {
|
|
1035
|
+
return this.localizationDevtools.getCurrentLanguage();
|
|
1036
|
+
}
|
|
1037
|
+
async switchLanguage(language) {
|
|
1038
|
+
const previous = this.localizationDevtools.getCurrentLanguage();
|
|
1039
|
+
await this.localizationDevtools.switchLanguage(language);
|
|
1040
|
+
return {
|
|
1041
|
+
requested: language,
|
|
1042
|
+
previous,
|
|
1043
|
+
current: this.localizationDevtools.getCurrentLanguage()
|
|
1044
|
+
};
|
|
1045
|
+
}
|
|
1046
|
+
onLanguageChange(fn) {
|
|
1047
|
+
return this.localizationDevtools.onLanguageChange(fn);
|
|
1048
|
+
}
|
|
1049
|
+
updateLocalizationKeys(keyValues, language) {
|
|
1050
|
+
return this.localizationDevtools.updateLocalizationKeys(keyValues, language);
|
|
1051
|
+
}
|
|
1052
|
+
reloadLocalizationKeys(language) {
|
|
1053
|
+
return this.localizationDevtools.reloadLocalizationKeys(language);
|
|
1054
|
+
}
|
|
1055
|
+
static {
|
|
1056
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
1057
|
+
minVersion: "12.0.0",
|
|
1058
|
+
version: "22.2.3",
|
|
1059
|
+
ngImport: i0,
|
|
1060
|
+
type: LocalizationDevtoolsConsoleService,
|
|
1061
|
+
deps: [],
|
|
1062
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
1063
|
+
});
|
|
1064
|
+
}
|
|
1065
|
+
static {
|
|
1066
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
1067
|
+
minVersion: "12.0.0",
|
|
1068
|
+
version: "22.2.3",
|
|
1069
|
+
ngImport: i0,
|
|
1070
|
+
type: LocalizationDevtoolsConsoleService
|
|
1071
|
+
});
|
|
1072
|
+
}
|
|
1073
|
+
};
|
|
1074
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1075
|
+
minVersion: "12.0.0",
|
|
1076
|
+
version: "22.2.3",
|
|
1077
|
+
ngImport: i0,
|
|
1078
|
+
type: LocalizationDevtoolsConsoleService,
|
|
1079
|
+
decorators: [{ type: Injectable }],
|
|
1080
|
+
ctorParameters: () => []
|
|
1081
|
+
});
|
|
1033
1082
|
const isLocalizationMessage = (message) => {
|
|
1034
|
-
|
|
1035
|
-
|| message.dataType === 'languages'
|
|
1036
|
-
|| message.dataType === 'switchLanguage'
|
|
1037
|
-
|| message.dataType === 'localizations'
|
|
1038
|
-
|| message.dataType === 'updateLocalization'
|
|
1039
|
-
|| message.dataType === 'requestMessages'
|
|
1040
|
-
|| message.dataType === 'connect'
|
|
1041
|
-
|| message.dataType === 'reloadLocalizationKeys'
|
|
1042
|
-
|| message.dataType === 'isTranslationDeactivationEnabled'
|
|
1043
|
-
|| message.dataType === 'getTranslationValuesContentMessage');
|
|
1083
|
+
return message && (message.dataType === "displayLocalizationKeys" || message.dataType === "languages" || message.dataType === "switchLanguage" || message.dataType === "localizations" || message.dataType === "updateLocalization" || message.dataType === "requestMessages" || message.dataType === "connect" || message.dataType === "reloadLocalizationKeys" || message.dataType === "isTranslationDeactivationEnabled" || message.dataType === "getTranslationValuesContentMessage");
|
|
1044
1084
|
};
|
|
1045
|
-
class LocalizationDevtoolsMessageService {
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1085
|
+
var LocalizationDevtoolsMessageService = class LocalizationDevtoolsMessageService {
|
|
1086
|
+
constructor() {
|
|
1087
|
+
this.logger = inject(LoggerService);
|
|
1088
|
+
this.localizationDevTools = inject(OtterLocalizationDevtools);
|
|
1089
|
+
this.localizationService = inject(LocalizationService);
|
|
1090
|
+
this.options = inject(OTTER_LOCALIZATION_DEVTOOLS_OPTIONS, { optional: true }) ?? OTTER_LOCALIZATION_DEVTOOLS_DEFAULT_OPTIONS;
|
|
1091
|
+
this.sendMessage = sendOtterMessage;
|
|
1092
|
+
this.destroyRef = inject(DestroyRef);
|
|
1093
|
+
this.options = {
|
|
1094
|
+
...OTTER_LOCALIZATION_DEVTOOLS_DEFAULT_OPTIONS,
|
|
1095
|
+
...this.options
|
|
1096
|
+
};
|
|
1097
|
+
if (this.options.isActivatedOnBootstrap) this.activate();
|
|
1098
|
+
}
|
|
1099
|
+
async sendLocalizationsMetadata() {
|
|
1100
|
+
const metadata = await (await fetch(this.options.metadataFilePath)).json();
|
|
1101
|
+
this.sendMessage("localizations", { localizations: metadata });
|
|
1102
|
+
}
|
|
1103
|
+
async handleReEmitRequest(only) {
|
|
1104
|
+
if (!only || only.includes("localizations")) this.sendLocalizationsMetadata();
|
|
1105
|
+
if (!only || only.includes("switchLanguage")) this.sendMessage("switchLanguage", { language: this.localizationDevTools.getCurrentLanguage() });
|
|
1106
|
+
if (!only || only.includes("languages")) this.sendMessage("languages", { languages: this.localizationService.getLanguages() });
|
|
1107
|
+
if (!only || only.includes("getTranslationValuesContentMessage")) this.sendMessage("getTranslationValuesContentMessage", { translations: await firstValueFrom(this.localizationService.getTranslateService().getTranslation(this.localizationService.getCurrentLanguage())) });
|
|
1108
|
+
if (!only || only.includes("isTranslationDeactivationEnabled")) this.sendMessage("isTranslationDeactivationEnabled", { enabled: this.localizationService.isTranslationDeactivationEnabled() });
|
|
1109
|
+
}
|
|
1110
|
+
handleEvents(message) {
|
|
1111
|
+
this.logger.debug("Message handling by the localization service", message);
|
|
1112
|
+
switch (message.dataType) {
|
|
1113
|
+
case "connect":
|
|
1114
|
+
this.connectPlugin();
|
|
1115
|
+
break;
|
|
1116
|
+
case "displayLocalizationKeys":
|
|
1117
|
+
this.localizationDevTools.showLocalizationKeys(message.toggle);
|
|
1118
|
+
break;
|
|
1119
|
+
case "requestMessages":
|
|
1120
|
+
this.handleReEmitRequest(message.only);
|
|
1121
|
+
break;
|
|
1122
|
+
case "switchLanguage":
|
|
1123
|
+
this.localizationDevTools.switchLanguage(message.language);
|
|
1124
|
+
break;
|
|
1125
|
+
case "updateLocalization":
|
|
1126
|
+
this.localizationDevTools.updateLocalizationKeys({ [message.key]: message.value }, message.lang);
|
|
1127
|
+
break;
|
|
1128
|
+
case "reloadLocalizationKeys":
|
|
1129
|
+
this.localizationDevTools.reloadLocalizationKeys(message.lang);
|
|
1130
|
+
break;
|
|
1131
|
+
default: this.logger.warn("Message ignored by the localization service", message);
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
connectPlugin() {
|
|
1135
|
+
this.logger.debug("Otter DevTools is plugged to localization service of the application");
|
|
1136
|
+
}
|
|
1137
|
+
activate() {
|
|
1138
|
+
fromEvent(window, "message").pipe(takeUntilDestroyed(this.destroyRef), filterMessageContent(isLocalizationMessage)).subscribe((e) => this.handleEvents(e));
|
|
1139
|
+
}
|
|
1140
|
+
static {
|
|
1141
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
1142
|
+
minVersion: "12.0.0",
|
|
1143
|
+
version: "22.2.3",
|
|
1144
|
+
ngImport: i0,
|
|
1145
|
+
type: LocalizationDevtoolsMessageService,
|
|
1146
|
+
deps: [],
|
|
1147
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
1148
|
+
});
|
|
1149
|
+
}
|
|
1150
|
+
static {
|
|
1151
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
1152
|
+
minVersion: "12.0.0",
|
|
1153
|
+
version: "22.2.3",
|
|
1154
|
+
ngImport: i0,
|
|
1155
|
+
type: LocalizationDevtoolsMessageService
|
|
1156
|
+
});
|
|
1157
|
+
}
|
|
1158
|
+
};
|
|
1159
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1160
|
+
minVersion: "12.0.0",
|
|
1161
|
+
version: "22.2.3",
|
|
1162
|
+
ngImport: i0,
|
|
1163
|
+
type: LocalizationDevtoolsMessageService,
|
|
1164
|
+
decorators: [{ type: Injectable }],
|
|
1165
|
+
ctorParameters: () => []
|
|
1166
|
+
});
|
|
1167
|
+
var LocalizationDevtoolsModule = class LocalizationDevtoolsModule {
|
|
1168
|
+
static instrument(options) {
|
|
1169
|
+
return {
|
|
1170
|
+
ngModule: LocalizationDevtoolsModule,
|
|
1171
|
+
providers: [
|
|
1172
|
+
{
|
|
1173
|
+
provide: OTTER_LOCALIZATION_DEVTOOLS_OPTIONS,
|
|
1174
|
+
useValue: {
|
|
1175
|
+
...OTTER_LOCALIZATION_DEVTOOLS_DEFAULT_OPTIONS,
|
|
1176
|
+
...options
|
|
1177
|
+
},
|
|
1178
|
+
multi: false
|
|
1179
|
+
},
|
|
1180
|
+
LocalizationDevtoolsMessageService,
|
|
1181
|
+
LocalizationDevtoolsConsoleService,
|
|
1182
|
+
OtterLocalizationDevtools
|
|
1183
|
+
]
|
|
1184
|
+
};
|
|
1185
|
+
}
|
|
1186
|
+
static {
|
|
1187
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
1188
|
+
minVersion: "12.0.0",
|
|
1189
|
+
version: "22.2.3",
|
|
1190
|
+
ngImport: i0,
|
|
1191
|
+
type: LocalizationDevtoolsModule,
|
|
1192
|
+
deps: [],
|
|
1193
|
+
target: i0.ɵɵFactoryTarget.NgModule
|
|
1194
|
+
});
|
|
1195
|
+
}
|
|
1196
|
+
static {
|
|
1197
|
+
this.ɵmod = i0.ɵɵngDeclareNgModule({
|
|
1198
|
+
minVersion: "14.0.0",
|
|
1199
|
+
version: "22.2.3",
|
|
1200
|
+
ngImport: i0,
|
|
1201
|
+
type: LocalizationDevtoolsModule,
|
|
1202
|
+
imports: [LocalizationModule]
|
|
1203
|
+
});
|
|
1204
|
+
}
|
|
1205
|
+
static {
|
|
1206
|
+
this.ɵinj = i0.ɵɵngDeclareInjector({
|
|
1207
|
+
minVersion: "12.0.0",
|
|
1208
|
+
version: "22.2.3",
|
|
1209
|
+
ngImport: i0,
|
|
1210
|
+
type: LocalizationDevtoolsModule,
|
|
1211
|
+
providers: [
|
|
1212
|
+
{
|
|
1213
|
+
provide: OTTER_LOCALIZATION_DEVTOOLS_OPTIONS,
|
|
1214
|
+
useValue: OTTER_LOCALIZATION_DEVTOOLS_DEFAULT_OPTIONS
|
|
1215
|
+
},
|
|
1216
|
+
LocalizationDevtoolsMessageService,
|
|
1217
|
+
LocalizationDevtoolsConsoleService,
|
|
1218
|
+
OtterLocalizationDevtools
|
|
1219
|
+
],
|
|
1220
|
+
imports: [LocalizationModule]
|
|
1221
|
+
});
|
|
1222
|
+
}
|
|
1223
|
+
};
|
|
1224
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1225
|
+
minVersion: "12.0.0",
|
|
1226
|
+
version: "22.2.3",
|
|
1227
|
+
ngImport: i0,
|
|
1228
|
+
type: LocalizationDevtoolsModule,
|
|
1229
|
+
decorators: [{
|
|
1230
|
+
type: NgModule,
|
|
1231
|
+
args: [{
|
|
1232
|
+
imports: [LocalizationModule],
|
|
1233
|
+
providers: [
|
|
1234
|
+
{
|
|
1235
|
+
provide: OTTER_LOCALIZATION_DEVTOOLS_OPTIONS,
|
|
1236
|
+
useValue: OTTER_LOCALIZATION_DEVTOOLS_DEFAULT_OPTIONS
|
|
1237
|
+
},
|
|
1238
|
+
LocalizationDevtoolsMessageService,
|
|
1239
|
+
LocalizationDevtoolsConsoleService,
|
|
1240
|
+
OtterLocalizationDevtools
|
|
1241
|
+
]
|
|
1242
|
+
}]
|
|
1243
|
+
}]
|
|
1244
|
+
});
|
|
1189
1245
|
export { CUSTOM_LOCALIZATION_CONFIGURATION_TOKEN, DEFAULT_LOCALIZATION_CONFIGURATION, LOCALIZATION_CONFIGURATION_TOKEN, LOCALIZATION_OVERRIDE_REDUCER_TOKEN, LOCALIZATION_OVERRIDE_STORE_NAME, Localization, LocalizationDevtoolsConsoleService, LocalizationDevtoolsMessageService, LocalizationDevtoolsModule, LocalizationModule, LocalizationOverrideStoreModule, LocalizationService, LocalizationTranslateDirective, LocalizedCurrencyPipe, LocalizedDatePipe, LocalizedDecimalPipe, MESSAGE_FORMAT_CONFIG, O3rLocalizationTranslatePipe, OTTER_LOCALIZATION_DEVTOOLS_DEFAULT_OPTIONS, OTTER_LOCALIZATION_DEVTOOLS_OPTIONS, OtterLocalizationDevtools, TextDirectionService, TextDirectionality, TranslateMessageFormatLazyCompiler, TranslationsLoader, createLocalizationConfiguration, createTranslateLoader, getDefaultLocalizationOverrideReducer, lazyMessageDefaultConfig, localeIdNgBridge, localizationOverrideInitialState, localizationOverrideReducer, localizationOverrideReducerFeatures, localizationOverrideStorageDeserializer, localizationOverrideStorageSync, selectLocalizationOverride, selectLocalizationOverrideState, setLocalizationOverride, translateLoaderProvider };
|
|
1190
|
-
|
|
1246
|
+
|
|
1247
|
+
//# sourceMappingURL=o3r-localization.mjs.map
|