@tolgee/ngx 2.1.0 → 2.8.0

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.
@@ -0,0 +1,322 @@
1
+ import * as i0 from '@angular/core';
2
+ import { EventEmitter, Injectable, Pipe, Component, Input, APP_INITIALIZER, NgModule } from '@angular/core';
3
+ import { Observable } from 'rxjs';
4
+ import { Tolgee, TolgeeConfig, TOLGEE_WRAPPED_ONLY_DATA_ATTRIBUTE } from '@tolgee/core';
5
+ export { TolgeeConfig } from '@tolgee/core';
6
+
7
+ class TranslateService {
8
+ constructor(config) {
9
+ this.config = config;
10
+ this.onLangChange = new EventEmitter();
11
+ this.onTranslationChange = new EventEmitter();
12
+ }
13
+ get tolgee() {
14
+ return this._tolgee;
15
+ }
16
+ /**
17
+ * Starts Tolgee if not started and subscribes for languageChange and translationChange events
18
+ */
19
+ async start(config) {
20
+ if (!this.runPromise) {
21
+ this._tolgee = new Tolgee(config);
22
+ this.runPromise = this.tolgee.run();
23
+ // unsubscribe first, if it is subscribed for some reason
24
+ this.unsubscribeCoreListeners();
25
+ this.onTranslationChangeCoreSubscription =
26
+ this._tolgee.onTranslationChange.subscribe((data) => {
27
+ this.onTranslationChange.emit(data);
28
+ });
29
+ this.onLangChangeCoreSubscription = this._tolgee.onLangChange.subscribe(() => {
30
+ this.onLangChange.emit();
31
+ });
32
+ }
33
+ await this.runPromise;
34
+ }
35
+ ngOnDestroy() {
36
+ // stop it!
37
+ this.tolgee.stop();
38
+ // unsubscribe listeners
39
+ this.unsubscribeCoreListeners();
40
+ }
41
+ /**
42
+ * Changes the current language
43
+ * @param lang The new current language (e.g. en, en-US)
44
+ */
45
+ setLang(lang) {
46
+ this.tolgee.lang = lang;
47
+ }
48
+ /**
49
+ * Returns the current language
50
+ */
51
+ getCurrentLang() {
52
+ return this.tolgee.lang;
53
+ }
54
+ /**
55
+ * Returns Observable providing current translated value
56
+ * Tne observable is subscribed to translation change and language change events of Tolgee
57
+ *
58
+ * In development mode, it returns string wrapped with configured
59
+ * prefix and suffix to be handled in browser by MutationObserver.
60
+ *
61
+ * You should use unsubscribe method when you are done!
62
+ *
63
+ * in onInit: this.subscription = translateService.get('aa')
64
+ * in onDestroy: this.subscription.unsubscribe()
65
+ *
66
+ * @param key The key to translate (e.g. what-a-key)
67
+ * @param params The parameters to interpolate (e.g. {name: "John"})
68
+ * @param defaultValue Value, which will be rendered, when no translated value is provided
69
+ */
70
+ get(key, params = {}, defaultValue) {
71
+ return this.translate(key, params, false, defaultValue);
72
+ }
73
+ /**
74
+ * Returns Observable providing current translated value
75
+ * Tne observable is subscribed to translation change and language change events of Tolgee
76
+ *
77
+ * In development mode, it returns the translated string,
78
+ * so in-context localization is not going to work.
79
+ *
80
+ * You should use unsubscribe method when you are done!
81
+ *
82
+ * in onInit: this.subscription = translateService.get('aa')
83
+ * in onDestroy: this.subscription.unsubscribe()
84
+ *
85
+ * @param key The key to translate (e.g. what-a-key)
86
+ * @param params The parameters to interpolate (e.g. {name: "John"})
87
+ * @param defaultValue Value, which will be rendered, when no translated value is provided
88
+ */
89
+ getSafe(key, params = {}, defaultValue) {
90
+ return this.translate(key, params, true, defaultValue);
91
+ }
92
+ /**
93
+ * Returns the translation value synchronously
94
+ *
95
+ * In development mode, it returns string wrapped with configured
96
+ * prefix and suffix to be handled in browser by MutationObserver.
97
+ *
98
+ * @param key The key to translate (e.g. what-a-key)
99
+ * @param params The parameters to interpolate (e.g. {name: "John"})
100
+ * @param defaultValue Value, which will be rendered, when no translated value is provided
101
+ */
102
+ instant(key, params = {}, defaultValue) {
103
+ return this.tolgee.instant(key, params, undefined, undefined, defaultValue);
104
+ }
105
+ /**
106
+ * Returns the translation value synchronously
107
+ *
108
+ * In development mode, it returns the translated string,
109
+ * so in-context localization is not going to work.
110
+ *
111
+ * @param key The key to translate (e.g. what-a-key)
112
+ * @param params The parameters to interpolate (e.g. {name: "John"})
113
+ * @param defaultValue Value, which will be rendered, when no translated value is provided
114
+ */
115
+ instantSafe(input, params = {}, defaultValue) {
116
+ return this.tolgee.instant(input, params, true, undefined, defaultValue);
117
+ }
118
+ unsubscribeCoreListeners() {
119
+ this.onTranslationChangeCoreSubscription?.unsubscribe();
120
+ this.onLangChangeCoreSubscription?.unsubscribe();
121
+ }
122
+ translate(key, params = {}, noWrap = false, defaultValue) {
123
+ return new Observable((subscriber) => {
124
+ const translate = async () => {
125
+ // start if not started
126
+ await this.start(this.config);
127
+ const translated = await this.tolgee.translate(key, params, noWrap, defaultValue);
128
+ subscriber.next(translated);
129
+ };
130
+ translate();
131
+ const onTranslationChangeSubscription = this.tolgee.onTranslationChange.subscribe((data) => {
132
+ if (data.key === key) {
133
+ translate();
134
+ }
135
+ });
136
+ const onLanguageChangeSubscription = this.tolgee.onLangChange.subscribe(() => {
137
+ translate();
138
+ });
139
+ return () => {
140
+ onTranslationChangeSubscription.unsubscribe();
141
+ onLanguageChangeSubscription.unsubscribe();
142
+ };
143
+ });
144
+ }
145
+ }
146
+ TranslateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: TranslateService, deps: [{ token: TolgeeConfig }], target: i0.ɵɵFactoryTarget.Injectable });
147
+ TranslateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: TranslateService });
148
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: TranslateService, decorators: [{
149
+ type: Injectable
150
+ }], ctorParameters: function () { return [{ type: TolgeeConfig }]; } });
151
+
152
+ class TranslatePipe {
153
+ constructor(translateService) {
154
+ this.translateService = translateService;
155
+ this.value = '';
156
+ }
157
+ get resultProvider() {
158
+ return (key, params, defaultValue) => this.translateService.get(key, params, defaultValue);
159
+ }
160
+ ngOnDestroy() {
161
+ this.unsubscribe();
162
+ }
163
+ transform(key, paramsOrDefaultValue, params) {
164
+ if (!key || key.length === 0) {
165
+ return key;
166
+ }
167
+ const defaultValue = typeof paramsOrDefaultValue !== 'object'
168
+ ? paramsOrDefaultValue
169
+ : undefined;
170
+ if (typeof paramsOrDefaultValue === 'object') {
171
+ params = paramsOrDefaultValue;
172
+ }
173
+ if (this.key === key &&
174
+ JSON.stringify(this.params) === JSON.stringify(params) &&
175
+ this.defaultValue === defaultValue) {
176
+ return this.value;
177
+ }
178
+ this.key = key;
179
+ this.params = params;
180
+ this.defaultValue = defaultValue;
181
+ // unsubscribe first
182
+ this.unsubscribe();
183
+ // asynchronously translate and assign subscription
184
+ this.subscription = this.translate(key, params, defaultValue);
185
+ return this.value;
186
+ }
187
+ unsubscribe() {
188
+ if (this.subscription) {
189
+ this.subscription.unsubscribe();
190
+ }
191
+ }
192
+ translate(key, params, defaultValue) {
193
+ return this.resultProvider(key, params, defaultValue).subscribe((r) => {
194
+ this.value = r;
195
+ });
196
+ }
197
+ }
198
+ TranslatePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: TranslatePipe, deps: [{ token: TranslateService }], target: i0.ɵɵFactoryTarget.Pipe });
199
+ TranslatePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: TranslatePipe, name: "translate", pure: false });
200
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: TranslatePipe, decorators: [{
201
+ type: Pipe,
202
+ args: [{
203
+ name: 'translate',
204
+ pure: false,
205
+ }]
206
+ }], ctorParameters: function () { return [{ type: TranslateService }]; } });
207
+
208
+ class STranslatePipe extends TranslatePipe {
209
+ constructor(translateService) {
210
+ super(translateService);
211
+ }
212
+ get resultProvider() {
213
+ return (input, params, defaultValue) => this.translateService.getSafe(input, params, defaultValue);
214
+ }
215
+ }
216
+ STranslatePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: STranslatePipe, deps: [{ token: TranslateService }], target: i0.ɵɵFactoryTarget.Pipe });
217
+ STranslatePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: STranslatePipe, name: "stranslate", pure: false });
218
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: STranslatePipe, decorators: [{
219
+ type: Pipe,
220
+ args: [{
221
+ name: 'stranslate',
222
+ pure: false,
223
+ }]
224
+ }], ctorParameters: function () { return [{ type: TranslateService }]; } });
225
+
226
+ class TComponent {
227
+ constructor(ref, translateService) {
228
+ this.ref = ref;
229
+ this.translateService = translateService;
230
+ }
231
+ ngOnInit() {
232
+ const element = this.ref.nativeElement;
233
+ element.setAttribute(TOLGEE_WRAPPED_ONLY_DATA_ATTRIBUTE, this.key);
234
+ // set safe at first
235
+ element.textContent = this.translateService.instantSafe(this.key, this.params, this.default);
236
+ // then do the async translation
237
+ this.subscription = this.translateService
238
+ .getSafe(this.key, this.params, this.default)
239
+ .subscribe((translated) => {
240
+ return (element.textContent = translated);
241
+ });
242
+ }
243
+ ngOnDestroy() {
244
+ if (this.subscription) {
245
+ this.subscription.unsubscribe();
246
+ }
247
+ }
248
+ }
249
+ TComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: TComponent, deps: [{ token: i0.ElementRef }, { token: TranslateService }], target: i0.ɵɵFactoryTarget.Component });
250
+ TComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.2", type: TComponent, selector: "[t]", inputs: { params: "params", key: "key", default: "default" }, ngImport: i0, template: ``, isInline: true });
251
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: TComponent, decorators: [{
252
+ type: Component,
253
+ args: [{
254
+ selector: '[t]',
255
+ template: ``,
256
+ }]
257
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: TranslateService }]; }, propDecorators: { params: [{
258
+ type: Input
259
+ }], key: [{
260
+ type: Input
261
+ }], default: [{
262
+ type: Input
263
+ }] } });
264
+
265
+ class TranslationsProvider {
266
+ constructor(translateService) {
267
+ this.translateService = translateService;
268
+ }
269
+ async load(options) {
270
+ return await this.translateService.start(options);
271
+ }
272
+ }
273
+ TranslationsProvider.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: TranslationsProvider, deps: [{ token: TranslateService }], target: i0.ɵɵFactoryTarget.Injectable });
274
+ TranslationsProvider.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: TranslationsProvider });
275
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: TranslationsProvider, decorators: [{
276
+ type: Injectable
277
+ }], ctorParameters: function () { return [{ type: TranslateService }]; } });
278
+
279
+ class NgxTolgeeModule {
280
+ // @dynamic
281
+ static forRoot(options) {
282
+ options = { filesUrlPrefix: '/assets/i18n/', ...options };
283
+ return {
284
+ ngModule: NgxTolgeeModule,
285
+ providers: [
286
+ TranslateService,
287
+ TranslationsProvider,
288
+ {
289
+ provide: APP_INITIALIZER,
290
+ useFactory: (provider) => {
291
+ return async () => await provider.load(options);
292
+ },
293
+ deps: [TranslationsProvider, TranslateService],
294
+ multi: true,
295
+ },
296
+ { provide: TolgeeConfig, useValue: options },
297
+ ],
298
+ };
299
+ }
300
+ }
301
+ NgxTolgeeModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: NgxTolgeeModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
302
+ NgxTolgeeModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: NgxTolgeeModule, declarations: [TranslatePipe, STranslatePipe, TComponent], exports: [TranslatePipe, STranslatePipe, TComponent] });
303
+ NgxTolgeeModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: NgxTolgeeModule, providers: [] });
304
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: NgxTolgeeModule, decorators: [{
305
+ type: NgModule,
306
+ args: [{
307
+ declarations: [TranslatePipe, STranslatePipe, TComponent],
308
+ exports: [TranslatePipe, STranslatePipe, TComponent],
309
+ providers: [],
310
+ }]
311
+ }] });
312
+
313
+ /*
314
+ * Public API Surface of ngx-tolgee
315
+ */
316
+
317
+ /**
318
+ * Generated bundle index. Do not edit.
319
+ */
320
+
321
+ export { NgxTolgeeModule, STranslatePipe, TComponent, TranslatePipe, TranslateService };
322
+ //# sourceMappingURL=tolgee-ngx.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tolgee-ngx.mjs","sources":["../../../projects/ngx-tolgee/src/lib/translate.service.ts","../../../projects/ngx-tolgee/src/lib/translate.pipe.ts","../../../projects/ngx-tolgee/src/lib/stranslate.pipe.ts","../../../projects/ngx-tolgee/src/lib/t.component.ts","../../../projects/ngx-tolgee/src/lib/translations-provider.ts","../../../projects/ngx-tolgee/src/lib/ngx-tolgee.module.ts","../../../projects/ngx-tolgee/src/public-api.ts","../../../projects/ngx-tolgee/src/tolgee-ngx.ts"],"sourcesContent":["import { EventEmitter, Injectable, OnDestroy } from '@angular/core';\nimport { Observable } from 'rxjs';\nimport { Tolgee, TranslationData } from '@tolgee/core';\nimport { TolgeeConfig } from './tolgeeConfig';\n\n@Injectable()\nexport class TranslateService implements OnDestroy {\n public readonly onLangChange: EventEmitter<never> = new EventEmitter<never>();\n public readonly onTranslationChange: EventEmitter<TranslationData> =\n new EventEmitter<TranslationData>();\n\n private runPromise: Promise<void>;\n private onTranslationChangeCoreSubscription: any;\n private onLangChangeCoreSubscription: any;\n\n constructor(private config: TolgeeConfig) {}\n\n private _tolgee: Tolgee;\n\n public get tolgee(): Tolgee {\n return this._tolgee;\n }\n\n /**\n * Starts Tolgee if not started and subscribes for languageChange and translationChange events\n */\n public async start(config: TolgeeConfig): Promise<void> {\n if (!this.runPromise) {\n this._tolgee = new Tolgee(config);\n this.runPromise = this.tolgee.run();\n // unsubscribe first, if it is subscribed for some reason\n this.unsubscribeCoreListeners();\n this.onTranslationChangeCoreSubscription =\n this._tolgee.onTranslationChange.subscribe((data) => {\n this.onTranslationChange.emit(data);\n });\n this.onLangChangeCoreSubscription = this._tolgee.onLangChange.subscribe(\n () => {\n this.onLangChange.emit();\n }\n );\n }\n await this.runPromise;\n }\n\n ngOnDestroy(): void {\n // stop it!\n this.tolgee.stop();\n // unsubscribe listeners\n this.unsubscribeCoreListeners();\n }\n\n /**\n * Changes the current language\n * @param lang The new current language (e.g. en, en-US)\n */\n public setLang(lang: string) {\n this.tolgee.lang = lang;\n }\n\n /**\n * Returns the current language\n */\n public getCurrentLang(): string {\n return this.tolgee.lang;\n }\n\n /**\n * Returns Observable providing current translated value\n * Tne observable is subscribed to translation change and language change events of Tolgee\n *\n * In development mode, it returns string wrapped with configured\n * prefix and suffix to be handled in browser by MutationObserver.\n *\n * You should use unsubscribe method when you are done!\n *\n * in onInit: this.subscription = translateService.get('aa')\n * in onDestroy: this.subscription.unsubscribe()\n *\n * @param key The key to translate (e.g. what-a-key)\n * @param params The parameters to interpolate (e.g. {name: \"John\"})\n * @param defaultValue Value, which will be rendered, when no translated value is provided\n */\n public get(\n key: string,\n params = {},\n defaultValue?: string\n ): Observable<string> {\n return this.translate(key, params, false, defaultValue);\n }\n\n /**\n * Returns Observable providing current translated value\n * Tne observable is subscribed to translation change and language change events of Tolgee\n *\n * In development mode, it returns the translated string,\n * so in-context localization is not going to work.\n *\n * You should use unsubscribe method when you are done!\n *\n * in onInit: this.subscription = translateService.get('aa')\n * in onDestroy: this.subscription.unsubscribe()\n *\n * @param key The key to translate (e.g. what-a-key)\n * @param params The parameters to interpolate (e.g. {name: \"John\"})\n * @param defaultValue Value, which will be rendered, when no translated value is provided\n */\n public getSafe(\n key: string,\n params = {},\n defaultValue?: string\n ): Observable<string> {\n return this.translate(key, params, true, defaultValue);\n }\n\n /**\n * Returns the translation value synchronously\n *\n * In development mode, it returns string wrapped with configured\n * prefix and suffix to be handled in browser by MutationObserver.\n *\n * @param key The key to translate (e.g. what-a-key)\n * @param params The parameters to interpolate (e.g. {name: \"John\"})\n * @param defaultValue Value, which will be rendered, when no translated value is provided\n */\n public instant(key: string, params = {}, defaultValue?: string): string {\n return this.tolgee.instant(key, params, undefined, undefined, defaultValue);\n }\n\n /**\n * Returns the translation value synchronously\n *\n * In development mode, it returns the translated string,\n * so in-context localization is not going to work.\n *\n * @param key The key to translate (e.g. what-a-key)\n * @param params The parameters to interpolate (e.g. {name: \"John\"})\n * @param defaultValue Value, which will be rendered, when no translated value is provided\n */\n public instantSafe(\n input: string,\n params = {},\n defaultValue?: string\n ): string {\n return this.tolgee.instant(input, params, true, undefined, defaultValue);\n }\n\n private unsubscribeCoreListeners() {\n this.onTranslationChangeCoreSubscription?.unsubscribe();\n this.onLangChangeCoreSubscription?.unsubscribe();\n }\n\n private translate(\n key: string,\n params = {},\n noWrap = false,\n defaultValue: string\n ): Observable<string> {\n return new Observable((subscriber) => {\n const translate = async () => {\n // start if not started\n await this.start(this.config);\n const translated = await this.tolgee.translate(\n key,\n params,\n noWrap,\n defaultValue\n );\n\n subscriber.next(translated);\n };\n\n translate();\n\n const onTranslationChangeSubscription =\n this.tolgee.onTranslationChange.subscribe((data) => {\n if (data.key === key) {\n translate();\n }\n });\n\n const onLanguageChangeSubscription = this.tolgee.onLangChange.subscribe(\n () => {\n translate();\n }\n );\n\n return () => {\n onTranslationChangeSubscription.unsubscribe();\n onLanguageChangeSubscription.unsubscribe();\n };\n });\n }\n}\n","import { OnDestroy, Pipe, PipeTransform } from '@angular/core';\nimport { TranslateService } from './translate.service';\nimport { Observable, Subscription } from 'rxjs';\n\n@Pipe({\n name: 'translate',\n pure: false,\n})\nexport class TranslatePipe implements PipeTransform, OnDestroy {\n value = '';\n key: string;\n params: Record<string, any>;\n defaultValue: string;\n private;\n private subscription: Subscription;\n\n constructor(protected translateService: TranslateService) {}\n\n protected get resultProvider(): (\n key,\n params,\n defaultValue: string\n ) => Observable<string> {\n return (key, params, defaultValue) =>\n this.translateService.get(key, params, defaultValue);\n }\n\n ngOnDestroy(): void {\n this.unsubscribe();\n }\n\n transform(key: any, params?: Record<string, any>): string;\n\n transform(\n key: any,\n defaultValue?: string,\n params?: Record<string, any>\n ): string;\n\n transform(\n key: any,\n paramsOrDefaultValue?: Record<string, any> | string,\n params?: Record<string, any>\n ): string {\n if (!key || key.length === 0) {\n return key;\n }\n\n const defaultValue =\n typeof paramsOrDefaultValue !== 'object'\n ? paramsOrDefaultValue\n : undefined;\n\n if (typeof paramsOrDefaultValue === 'object') {\n params = paramsOrDefaultValue;\n }\n\n if (\n this.key === key &&\n JSON.stringify(this.params) === JSON.stringify(params) &&\n this.defaultValue === defaultValue\n ) {\n return this.value;\n }\n\n this.key = key;\n this.params = params;\n this.defaultValue = defaultValue;\n\n // unsubscribe first\n this.unsubscribe();\n\n // asynchronously translate and assign subscription\n this.subscription = this.translate(key, params, defaultValue);\n\n return this.value;\n }\n\n private unsubscribe() {\n if (this.subscription) {\n this.subscription.unsubscribe();\n }\n }\n\n private translate(key, params, defaultValue) {\n return this.resultProvider(key, params, defaultValue).subscribe((r) => {\n this.value = r;\n });\n }\n}\n","import { Pipe } from '@angular/core';\nimport { TranslateService } from './translate.service';\nimport { TranslatePipe } from './translate.pipe';\nimport { Observable } from 'rxjs';\n\n@Pipe({\n name: 'stranslate',\n pure: false,\n})\nexport class STranslatePipe extends TranslatePipe {\n constructor(translateService: TranslateService) {\n super(translateService);\n }\n\n protected get resultProvider(): (\n input,\n params,\n defaultValue\n ) => Observable<string> {\n return (input, params, defaultValue) =>\n this.translateService.getSafe(input, params, defaultValue);\n }\n}\n","import { Component, ElementRef, Input, OnDestroy, OnInit } from '@angular/core';\nimport { Subscription } from 'rxjs';\nimport { TranslateService } from './translate.service';\nimport { TOLGEE_WRAPPED_ONLY_DATA_ATTRIBUTE } from '@tolgee/core';\n\n@Component({\n selector: '[t]',\n template: ``,\n})\nexport class TComponent implements OnInit, OnDestroy {\n @Input() params?: Record<string, any>;\n @Input() key: string;\n @Input() default?: string;\n subscription: Subscription;\n\n constructor(\n private ref: ElementRef,\n private translateService: TranslateService\n ) {}\n\n ngOnInit(): void {\n const element = this.ref.nativeElement as HTMLElement;\n element.setAttribute(TOLGEE_WRAPPED_ONLY_DATA_ATTRIBUTE, this.key);\n\n // set safe at first\n element.textContent = this.translateService.instantSafe(\n this.key,\n this.params,\n this.default\n );\n\n // then do the async translation\n this.subscription = this.translateService\n .getSafe(this.key, this.params, this.default)\n .subscribe((translated) => {\n return (element.textContent = translated);\n });\n }\n\n ngOnDestroy(): void {\n if (this.subscription) {\n this.subscription.unsubscribe();\n }\n }\n}\n","import {Injectable} from '@angular/core';\nimport {TranslateService} from \"./translate.service\";\nimport {TolgeeConfig} from \"@tolgee/core\";\n\n@Injectable()\nexport class TranslationsProvider {\n\n constructor(private translateService: TranslateService) {\n }\n\n async load(options: TolgeeConfig) {\n return await this.translateService.start(options);\n }\n}\n\n\n","import { APP_INITIALIZER, ModuleWithProviders, NgModule } from '@angular/core';\nimport { TranslatePipe } from './translate.pipe';\nimport { TranslationsProvider } from './translations-provider';\nimport { TranslateService } from './translate.service';\nimport { STranslatePipe } from './stranslate.pipe';\nimport { TolgeeConfig } from './tolgeeConfig';\nimport { TComponent } from './t.component';\n\n@NgModule({\n declarations: [TranslatePipe, STranslatePipe, TComponent],\n exports: [TranslatePipe, STranslatePipe, TComponent],\n providers: [],\n})\nexport class NgxTolgeeModule {\n // @dynamic\n static forRoot(options: TolgeeConfig): ModuleWithProviders<NgxTolgeeModule> {\n options = { filesUrlPrefix: '/assets/i18n/', ...options };\n return {\n ngModule: NgxTolgeeModule,\n providers: [\n TranslateService,\n TranslationsProvider,\n {\n provide: APP_INITIALIZER,\n useFactory: (provider: TranslationsProvider) => {\n return async () => await provider.load(options);\n },\n deps: [TranslationsProvider, TranslateService],\n multi: true,\n },\n { provide: TolgeeConfig, useValue: options },\n ],\n };\n }\n}\n","/*\n * Public API Surface of ngx-tolgee\n */\nimport { TranslateService } from './lib/translate.service';\nimport { TranslatePipe } from './lib/translate.pipe';\nimport { STranslatePipe } from './lib/stranslate.pipe';\nimport { TolgeeConfig } from './lib/tolgeeConfig';\nimport { TComponent } from './lib/t.component';\n\nexport * from './lib/ngx-tolgee.module';\nexport { TolgeeConfig };\nexport { TranslateService };\nexport { TranslatePipe };\nexport { STranslatePipe };\nexport { TComponent };\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;MAMa,gBAAgB;IAS3B,YAAoB,MAAoB;QAApB,WAAM,GAAN,MAAM,CAAc;QARxB,iBAAY,GAAwB,IAAI,YAAY,EAAS,CAAC;QAC9D,wBAAmB,GACjC,IAAI,YAAY,EAAmB,CAAC;KAMM;IAI5C,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,OAAO,CAAC;KACrB;;;;IAKM,MAAM,KAAK,CAAC,MAAoB;QACrC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YACpB,IAAI,CAAC,OAAO,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC;YAClC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;;YAEpC,IAAI,CAAC,wBAAwB,EAAE,CAAC;YAChC,IAAI,CAAC,mCAAmC;gBACtC,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC,IAAI;oBAC9C,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;iBACrC,CAAC,CAAC;YACL,IAAI,CAAC,4BAA4B,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS,CACrE;gBACE,IAAI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AE,UAAU,CAAC;oBACpD,SAAS,EAAE,EAAE;iBACd;;;ACZD;;;;ACAA;;;;;;"}
@@ -1,5 +1,12 @@
1
1
  import { ModuleWithProviders } from '@angular/core';
2
2
  import { TolgeeConfig } from './tolgeeConfig';
3
+ import * as i0 from "@angular/core";
4
+ import * as i1 from "./translate.pipe";
5
+ import * as i2 from "./stranslate.pipe";
6
+ import * as i3 from "./t.component";
3
7
  export declare class NgxTolgeeModule {
4
8
  static forRoot(options: TolgeeConfig): ModuleWithProviders<NgxTolgeeModule>;
9
+ static ɵfac: i0.ɵɵFactoryDeclaration<NgxTolgeeModule, never>;
10
+ static ɵmod: i0.ɵɵNgModuleDeclaration<NgxTolgeeModule, [typeof i1.TranslatePipe, typeof i2.STranslatePipe, typeof i3.TComponent], never, [typeof i1.TranslatePipe, typeof i2.STranslatePipe, typeof i3.TComponent]>;
11
+ static ɵinj: i0.ɵɵInjectorDeclaration<NgxTolgeeModule>;
5
12
  }
@@ -1,7 +1,10 @@
1
1
  import { TranslateService } from './translate.service';
2
2
  import { TranslatePipe } from './translate.pipe';
3
3
  import { Observable } from 'rxjs';
4
+ import * as i0 from "@angular/core";
4
5
  export declare class STranslatePipe extends TranslatePipe {
5
6
  constructor(translateService: TranslateService);
6
7
  protected get resultProvider(): (input: any, params: any, defaultValue: any) => Observable<string>;
8
+ static ɵfac: i0.ɵɵFactoryDeclaration<STranslatePipe, never>;
9
+ static ɵpipe: i0.ɵɵPipeDeclaration<STranslatePipe, "stranslate">;
7
10
  }
@@ -1,18 +1,17 @@
1
1
  import { ElementRef, OnDestroy, OnInit } from '@angular/core';
2
- import { Observable, Subscription } from 'rxjs';
2
+ import { Subscription } from 'rxjs';
3
3
  import { TranslateService } from './translate.service';
4
+ import * as i0 from "@angular/core";
4
5
  export declare class TComponent implements OnInit, OnDestroy {
5
6
  private ref;
6
7
  private translateService;
7
- value: string;
8
8
  params?: Record<string, any>;
9
9
  key: string;
10
10
  default?: string;
11
- onLangChangeSubscription: Subscription;
12
- onTranslationChangeSubscription: Subscription;
11
+ subscription: Subscription;
13
12
  constructor(ref: ElementRef, translateService: TranslateService);
14
- protected get resultProvider(): (key: any, params: any, defaultValue: string) => Observable<string>;
15
13
  ngOnInit(): void;
16
14
  ngOnDestroy(): void;
17
- private translate;
15
+ static ɵfac: i0.ɵɵFactoryDeclaration<TComponent, never>;
16
+ static ɵcmp: i0.ɵɵComponentDeclaration<TComponent, "[t]", never, { "params": "params"; "key": "key"; "default": "default"; }, {}, never, never>;
18
17
  }
@@ -1,16 +1,22 @@
1
1
  import { OnDestroy, PipeTransform } from '@angular/core';
2
2
  import { TranslateService } from './translate.service';
3
3
  import { Observable } from 'rxjs';
4
+ import * as i0 from "@angular/core";
4
5
  export declare class TranslatePipe implements PipeTransform, OnDestroy {
5
6
  protected translateService: TranslateService;
6
7
  value: string;
7
- lastHash: string;
8
- private langChangeSubscription;
8
+ key: string;
9
+ params: Record<string, any>;
10
+ defaultValue: string;
11
+ private: any;
12
+ private subscription;
9
13
  constructor(translateService: TranslateService);
10
14
  protected get resultProvider(): (key: any, params: any, defaultValue: string) => Observable<string>;
11
15
  ngOnDestroy(): void;
12
- transform(input: any, params?: Record<string, any>): string;
13
- transform(input: any, defaultValue?: string, params?: Record<string, any>): string;
14
- private getHash;
15
- private onLangChange;
16
+ transform(key: any, params?: Record<string, any>): string;
17
+ transform(key: any, defaultValue?: string, params?: Record<string, any>): string;
18
+ private unsubscribe;
19
+ private translate;
20
+ static ɵfac: i0.ɵɵFactoryDeclaration<TranslatePipe, never>;
21
+ static ɵpipe: i0.ɵɵPipeDeclaration<TranslatePipe, "translate">;
16
22
  }
@@ -2,6 +2,7 @@ import { EventEmitter, OnDestroy } from '@angular/core';
2
2
  import { Observable } from 'rxjs';
3
3
  import { Tolgee, TranslationData } from '@tolgee/core';
4
4
  import { TolgeeConfig } from './tolgeeConfig';
5
+ import * as i0 from "@angular/core";
5
6
  export declare class TranslateService implements OnDestroy {
6
7
  private config;
7
8
  readonly onLangChange: EventEmitter<never>;
@@ -12,14 +13,78 @@ export declare class TranslateService implements OnDestroy {
12
13
  constructor(config: TolgeeConfig);
13
14
  private _tolgee;
14
15
  get tolgee(): Tolgee;
16
+ /**
17
+ * Starts Tolgee if not started and subscribes for languageChange and translationChange events
18
+ */
15
19
  start(config: TolgeeConfig): Promise<void>;
16
20
  ngOnDestroy(): void;
21
+ /**
22
+ * Changes the current language
23
+ * @param lang The new current language (e.g. en, en-US)
24
+ */
17
25
  setLang(lang: string): void;
18
- get(input: string, params?: {}, defaultValue?: string): Observable<string>;
19
- getSafe(input: string, params?: {}, defaultValue?: string): Observable<string>;
20
- instant(input: string, params?: {}, defaultValue?: string): string;
21
- instantSafe(input: string, params?: {}, defaultValue?: string): string;
26
+ /**
27
+ * Returns the current language
28
+ */
22
29
  getCurrentLang(): string;
30
+ /**
31
+ * Returns Observable providing current translated value
32
+ * Tne observable is subscribed to translation change and language change events of Tolgee
33
+ *
34
+ * In development mode, it returns string wrapped with configured
35
+ * prefix and suffix to be handled in browser by MutationObserver.
36
+ *
37
+ * You should use unsubscribe method when you are done!
38
+ *
39
+ * in onInit: this.subscription = translateService.get('aa')
40
+ * in onDestroy: this.subscription.unsubscribe()
41
+ *
42
+ * @param key The key to translate (e.g. what-a-key)
43
+ * @param params The parameters to interpolate (e.g. {name: "John"})
44
+ * @param defaultValue Value, which will be rendered, when no translated value is provided
45
+ */
46
+ get(key: string, params?: {}, defaultValue?: string): Observable<string>;
47
+ /**
48
+ * Returns Observable providing current translated value
49
+ * Tne observable is subscribed to translation change and language change events of Tolgee
50
+ *
51
+ * In development mode, it returns the translated string,
52
+ * so in-context localization is not going to work.
53
+ *
54
+ * You should use unsubscribe method when you are done!
55
+ *
56
+ * in onInit: this.subscription = translateService.get('aa')
57
+ * in onDestroy: this.subscription.unsubscribe()
58
+ *
59
+ * @param key The key to translate (e.g. what-a-key)
60
+ * @param params The parameters to interpolate (e.g. {name: "John"})
61
+ * @param defaultValue Value, which will be rendered, when no translated value is provided
62
+ */
63
+ getSafe(key: string, params?: {}, defaultValue?: string): Observable<string>;
64
+ /**
65
+ * Returns the translation value synchronously
66
+ *
67
+ * In development mode, it returns string wrapped with configured
68
+ * prefix and suffix to be handled in browser by MutationObserver.
69
+ *
70
+ * @param key The key to translate (e.g. what-a-key)
71
+ * @param params The parameters to interpolate (e.g. {name: "John"})
72
+ * @param defaultValue Value, which will be rendered, when no translated value is provided
73
+ */
74
+ instant(key: string, params?: {}, defaultValue?: string): string;
75
+ /**
76
+ * Returns the translation value synchronously
77
+ *
78
+ * In development mode, it returns the translated string,
79
+ * so in-context localization is not going to work.
80
+ *
81
+ * @param key The key to translate (e.g. what-a-key)
82
+ * @param params The parameters to interpolate (e.g. {name: "John"})
83
+ * @param defaultValue Value, which will be rendered, when no translated value is provided
84
+ */
85
+ instantSafe(input: string, params?: {}, defaultValue?: string): string;
23
86
  private unsubscribeCoreListeners;
24
87
  private translate;
88
+ static ɵfac: i0.ɵɵFactoryDeclaration<TranslateService, never>;
89
+ static ɵprov: i0.ɵɵInjectableDeclaration<TranslateService>;
25
90
  }
@@ -1,7 +1,10 @@
1
1
  import { TranslateService } from "./translate.service";
2
2
  import { TolgeeConfig } from "@tolgee/core";
3
+ import * as i0 from "@angular/core";
3
4
  export declare class TranslationsProvider {
4
5
  private translateService;
5
6
  constructor(translateService: TranslateService);
6
7
  load(options: TolgeeConfig): Promise<void>;
8
+ static ɵfac: i0.ɵɵFactoryDeclaration<TranslationsProvider, never>;
9
+ static ɵprov: i0.ɵɵInjectableDeclaration<TranslationsProvider>;
7
10
  }
package/package.json CHANGED
@@ -5,20 +5,33 @@
5
5
  "type": "git",
6
6
  "url": "https://github.com/tolgee/tolgee-js"
7
7
  },
8
- "version": "2.1.0",
8
+ "dependencies": {
9
+ "@tolgee/core": "^2.8.0",
10
+ "tslib": "^2.3.0"
11
+ },
12
+ "version": "2.8.0",
9
13
  "publishConfig": {
10
14
  "directory": "../../dist/ngx-tolgee",
11
15
  "access": "public"
12
16
  },
13
- "main": "bundles/tolgee-ngx.umd.js",
14
- "module": "fesm2015/tolgee-ngx.js",
15
- "es2015": "fesm2015/tolgee-ngx.js",
16
- "esm2015": "esm2015/tolgee-ngx.js",
17
- "fesm2015": "fesm2015/tolgee-ngx.js",
17
+ "module": "fesm2015/tolgee-ngx.mjs",
18
+ "es2020": "fesm2020/tolgee-ngx.mjs",
19
+ "esm2020": "esm2020/tolgee-ngx.mjs",
20
+ "fesm2020": "fesm2020/tolgee-ngx.mjs",
21
+ "fesm2015": "fesm2015/tolgee-ngx.mjs",
18
22
  "typings": "tolgee-ngx.d.ts",
19
- "metadata": "tolgee-ngx.metadata.json",
20
- "sideEffects": false,
21
- "dependencies": {
22
- "tslib": "^2.2.0"
23
- }
23
+ "exports": {
24
+ "./package.json": {
25
+ "default": "./package.json"
26
+ },
27
+ ".": {
28
+ "types": "./tolgee-ngx.d.ts",
29
+ "esm2020": "./esm2020/tolgee-ngx.mjs",
30
+ "es2020": "./fesm2020/tolgee-ngx.mjs",
31
+ "es2015": "./fesm2015/tolgee-ngx.mjs",
32
+ "node": "./fesm2015/tolgee-ngx.mjs",
33
+ "default": "./fesm2020/tolgee-ngx.mjs"
34
+ }
35
+ },
36
+ "sideEffects": false
24
37
  }
package/tolgee-ngx.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  /**
2
2
  * Generated bundle index. Do not edit.
3
3
  */
4
+ /// <amd-module name="@tolgee/ngx" />
4
5
  export * from './public-api';