@siemens/element-translate-ng 47.9.0 → 48.0.0-next.2

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.
Files changed (34) hide show
  1. package/angular-localize/index.d.ts +21 -2
  2. package/fesm2022/siemens-element-translate-ng-angular-localize.mjs +10 -10
  3. package/fesm2022/siemens-element-translate-ng-ngx-translate.mjs +10 -10
  4. package/fesm2022/siemens-element-translate-ng-ngx-translate.mjs.map +1 -1
  5. package/fesm2022/siemens-element-translate-ng-translate.mjs +59 -47
  6. package/fesm2022/siemens-element-translate-ng-translate.mjs.map +1 -1
  7. package/index.d.ts +4 -5
  8. package/localize-types/index.d.ts +2 -7
  9. package/ngx-translate/index.d.ts +21 -2
  10. package/package.json +3 -3
  11. package/translate/index.d.ts +218 -11
  12. package/translate-types/index.d.ts +16 -1
  13. package/angular-localize/si-translate-ng-localize-service-builder.service.d.ts +0 -12
  14. package/angular-localize/si-translate-ng-localize.module.d.ts +0 -10
  15. package/angular-localize/si-translate-ng-localize.provider.d.ts +0 -10
  16. package/angular-localize/si-translate-ng-localize.service.d.ts +0 -7
  17. package/ngx-translate/si-translate-ngxt.module.d.ts +0 -10
  18. package/ngx-translate/si-translate-ngxt.provider.d.ts +0 -10
  19. package/ngx-translate/si-translate-ngxt.service-builder.d.ts +0 -19
  20. package/ngx-translate/si-translate-ngxt.service.d.ts +0 -28
  21. package/public-api.d.ts +0 -8
  22. package/translate/global.scope.d.ts +0 -8
  23. package/translate/si-localize.d.ts +0 -2
  24. package/translate/si-no-translate.service-builder.d.ts +0 -14
  25. package/translate/si-no-translate.service.d.ts +0 -21
  26. package/translate/si-translatable.model.d.ts +0 -6
  27. package/translate/si-translatable.service.d.ts +0 -11
  28. package/translate/si-translate.inject.d.ts +0 -2
  29. package/translate/si-translate.module.d.ts +0 -16
  30. package/translate/si-translate.pipe.d.ts +0 -30
  31. package/translate/si-translate.service-builder.d.ts +0 -21
  32. package/translate/si-translate.service.d.ts +0 -98
  33. package/translate/testing/si-translate.mock-service-builder.factory.d.ts +0 -7
  34. package/translate-types/global.types.d.ts +0 -19
@@ -1,15 +1,222 @@
1
+ import * as i0 from '@angular/core';
2
+ import { InjectionToken, PipeTransform, OnDestroy, Injector, Provider } from '@angular/core';
3
+ import { Observable } from 'rxjs';
4
+ import { TranslatableString } from '@siemens/element-translate-ng/translate-types';
5
+ export * from '@siemens/element-translate-ng/translate-types';
6
+
1
7
  /**
2
8
  * Copyright (c) Siemens 2016 - 2025
3
9
  * SPDX-License-Identifier: MIT
4
10
  */
5
- export * from './si-translatable.model';
6
- export * from './si-translate.module';
7
- export * from './si-translate.service';
8
- export * from './si-translate.service-builder';
9
- export * from './si-no-translate.service';
10
- export * from './si-translate.pipe';
11
- export * from './si-localize';
12
- export * from './si-translate.service';
13
- export * from './testing/si-translate.mock-service-builder.factory';
14
- export * from '@siemens/element-translate-ng/translate-types';
15
- export * from './si-translate.inject';
11
+
12
+ declare const SI_TRANSLATABLE_VALUES: InjectionToken<Record<string, string>[]>;
13
+
14
+ /**
15
+ * Copyright (c) Siemens 2016 - 2025
16
+ * SPDX-License-Identifier: MIT
17
+ */
18
+
19
+ /**
20
+ * Translates keys by using the {@link SiTranslateService}.
21
+ * Within Element this pipe should be used instead of ngx-translates `translate` pipe.
22
+ * Outside Element, this pipe should NOT be used.
23
+ *
24
+ * @internal
25
+ */
26
+ declare class SiTranslatePipe implements PipeTransform, OnDestroy {
27
+ private lastKeyParams?;
28
+ private value;
29
+ private subscription?;
30
+ private siTranslateService;
31
+ private cdRef;
32
+ /**
33
+ * Method which is called on any data passed to the pipe.
34
+ * Called by Angular, should not be called directly.
35
+ */
36
+ transform(key: string, params?: any): string;
37
+ transform(key: string | null | undefined, params?: any): string | null | undefined;
38
+ ngOnDestroy(): void;
39
+ private updateValue;
40
+ static ɵfac: i0.ɵɵFactoryDeclaration<SiTranslatePipe, never>;
41
+ static ɵpipe: i0.ɵɵPipeDeclaration<SiTranslatePipe, "translate", true>;
42
+ }
43
+
44
+ /**
45
+ * This provides declares SiTranslatePipe and provides a respective SiTranslateService.
46
+ * It should be used internally of Element but NOT by any application.
47
+ *
48
+ * @deprecated This module is no longer needed.
49
+ * Replace it with the {@link SiTranslatePipe} if needed, otherwise drop it without replacement.
50
+ *
51
+ * @internal
52
+ */
53
+ declare class SiTranslateModule {
54
+ static ɵfac: i0.ɵɵFactoryDeclaration<SiTranslateModule, never>;
55
+ static ɵmod: i0.ɵɵNgModuleDeclaration<SiTranslateModule, never, [typeof SiTranslatePipe], [typeof SiTranslatePipe]>;
56
+ static ɵinj: i0.ɵɵInjectorDeclaration<SiTranslateModule>;
57
+ }
58
+
59
+ type TranslationResult<T> = T extends string ? string : Record<string, string>;
60
+ /**
61
+ * @returns The culture language code of the browser, e.g. "en-US".
62
+ */
63
+ declare const getBrowserCultureLanguage: () => string | undefined;
64
+ /**
65
+ * @returns The language code of the browser, e.g. "en".
66
+ */
67
+ declare const getBrowserLanguage: () => string | undefined;
68
+ /**
69
+ * Wrapper around an actual translation framework which is meant to be used internally by Element.
70
+ * Applications must not use this service.
71
+ *
72
+ * Use {@link injectSiTranslateService} to get an instance of the translation service.
73
+ *
74
+ * @internal
75
+ */
76
+ declare abstract class SiTranslateService {
77
+ protected translationChange$: Observable<void>;
78
+ private documentRef;
79
+ prevent$LocalizeInit?: boolean;
80
+ /**
81
+ * The currently used language.
82
+ */
83
+ abstract get currentLanguage(): string;
84
+ /**
85
+ * Sets a new language to be used. If needed, loads the language file.
86
+ * @param lang - The language to be used.
87
+ * @returns An observable that emits when the new language is loaded and activated.
88
+ */
89
+ abstract setCurrentLanguage(lang: string): Observable<void>;
90
+ /**
91
+ * The language to be used as default.
92
+ * @param lang - The language code.
93
+ */
94
+ abstract setDefaultLanguage(lang: string): void;
95
+ /**
96
+ * The language to be used as default.
97
+ * @returns The code of the default language.
98
+ */
99
+ abstract getDefaultLanguage(): string;
100
+ /**
101
+ * The available languages.
102
+ */
103
+ abstract get availableLanguages(): string[];
104
+ abstract set availableLanguages(languages: string[]);
105
+ /**
106
+ * If the underlying translation library supports switching the language
107
+ * and/or updating the translation texts, this observable will emit.
108
+ * There is no initial emit.
109
+ */
110
+ get translationChange(): Observable<void>;
111
+ /**
112
+ * Translates the key(s) by using the underlying translation library.
113
+ *
114
+ * @param keys - A single translation key or an array of keys.
115
+ * @param params - Parameters to be replaced within the translation text.
116
+ *
117
+ * @returns Returns the translated key or an object with the translated keys.
118
+ * Depending on the underlying translation library (sync/async) the result will
119
+ * be wrapped in an Observable.
120
+ */
121
+ abstract translate<T extends string | string[]>(keys: T, params?: Record<string, unknown>): Observable<TranslationResult<T>> | TranslationResult<T>;
122
+ /**
123
+ * Translates the key(s) by using the underlying translation library in an asynchronous manner.
124
+ * It will emit each time the active language is changed.
125
+ *
126
+ * @param keys - A single translation key or an array of keys.
127
+ * @param params - Parameters to be replaced within the translation text.
128
+ *
129
+ * @returns Returns the translated key or an object with the translated keys wrapped in an Observable.
130
+ */
131
+ abstract translateAsync<T extends string | string[]>(keys: T, params?: Record<string, unknown>): Observable<TranslationResult<T>>;
132
+ /**
133
+ * Translates the key(s) by using the underlying translation library in a synchronous manner.
134
+ *
135
+ * Warning: The caller of this function needs to make sure the translation file(s) are already loaded.
136
+ * It is generally not recommended to use this function unless you know exactly what you are doing.
137
+ *
138
+ * @param keys - A single translation key or an array of keys.
139
+ * @param params - Parameters to be replaced within the translation text.
140
+ *
141
+ * @returns Returns the translated key or an object with the translated keys.
142
+ */
143
+ abstract translateSync<T extends string | string[]>(keys: T, params?: Record<string, unknown>): TranslationResult<T>;
144
+ /**
145
+ * If supported by the underlying translation library, this method can be used to add a translation for a specific key.
146
+ * It is intended to be used for adding the english default value.
147
+ * It will be called whenever a key within element is resolved.
148
+ * An implementation of this method must check that it does not override an existing translation.
149
+ */
150
+ setTranslation?(key: string, value: string): void;
151
+ setDocumentLanguage(lang: string): void;
152
+ static ɵfac: i0.ɵɵFactoryDeclaration<SiTranslateService, never>;
153
+ static ɵprov: i0.ɵɵInjectableDeclaration<SiTranslateService>;
154
+ }
155
+
156
+ /**
157
+ * Copyright (c) Siemens 2016 - 2025
158
+ * SPDX-License-Identifier: MIT
159
+ */
160
+
161
+ /**
162
+ * Provide this class to build a custom translation service.
163
+ *
164
+ * @internal
165
+ */
166
+ declare abstract class SiTranslateServiceBuilder {
167
+ /**
168
+ * Returns a translation service instance.
169
+ * @param injector - Is used to retrieve dependencies needed to create the translation service.
170
+ */
171
+ abstract buildService(injector: Injector): SiTranslateService;
172
+ static ɵfac: i0.ɵɵFactoryDeclaration<SiTranslateServiceBuilder, never>;
173
+ static ɵprov: i0.ɵɵInjectableDeclaration<SiTranslateServiceBuilder>;
174
+ }
175
+
176
+ /**
177
+ * Pass through implementation of the {@link SiTranslateService} which is used as a default.
178
+ *
179
+ * @internal
180
+ */
181
+ declare class SiNoTranslateService extends SiTranslateService {
182
+ get currentLanguage(): string;
183
+ get availableLanguages(): string[];
184
+ set availableLanguages(lang: string[]);
185
+ setCurrentLanguage(lang: string): Observable<void>;
186
+ getDefaultLanguage(): string;
187
+ setDefaultLanguage(lang: string): void;
188
+ translate<T extends string | string[]>(keys: T, _params?: Record<string, unknown>): TranslationResult<T>;
189
+ translateSync<T extends string | string[]>(keys: T, params?: Record<string, unknown>): TranslationResult<T>;
190
+ translateAsync<T extends string | string[]>(keys: T, params?: Record<string, unknown>): Observable<TranslationResult<T>>;
191
+ static ɵfac: i0.ɵɵFactoryDeclaration<SiNoTranslateService, never>;
192
+ static ɵprov: i0.ɵɵInjectableDeclaration<SiNoTranslateService>;
193
+ }
194
+
195
+ /**
196
+ * Copyright (c) Siemens 2016 - 2025
197
+ * SPDX-License-Identifier: MIT
198
+ */
199
+
200
+ declare const provideMockTranslateServiceBuilder: (buildService: (injector: Injector) => SiTranslateService) => Provider;
201
+
202
+ declare const injectSiTranslateService: () => SiTranslateService;
203
+
204
+ /**
205
+ * Always wrap `$localize` calls in this function within element components.
206
+ * It may patch the global $localize based on the current translation framework.
207
+ *
208
+ * This function requires an `InjectionContext.`
209
+ *
210
+ * @internal
211
+ *
212
+ * @example
213
+ * ```ts
214
+ * class MyComponent {
215
+ * readonly myText = t(() => $localize`:@@my-text:This is a default text`);
216
+ * }
217
+ * ```
218
+ */
219
+ declare const t: (localizeWrapperFunction: () => string) => TranslatableString;
220
+
221
+ export { SI_TRANSLATABLE_VALUES, SiNoTranslateService, SiTranslateModule, SiTranslatePipe, SiTranslateService, SiTranslateServiceBuilder, getBrowserCultureLanguage, getBrowserLanguage, injectSiTranslateService, provideMockTranslateServiceBuilder, t };
222
+ export type { TranslationResult };
@@ -2,4 +2,19 @@
2
2
  * Copyright (c) Siemens 2016 - 2025
3
3
  * SPDX-License-Identifier: MIT
4
4
  */
5
- export * from './global.types';
5
+ /**
6
+ * Empty interface to represent translatable strings before they are translated.
7
+ * Needed so the TypeScript compiler doesn't strip away the {@link TranslatableString} type.
8
+ * Ignored by the documentation.
9
+ * @internal
10
+ */
11
+ interface Translatable {
12
+ }
13
+ /**
14
+ * Represents a translatable string. This can either be a translation key, e.g. `ACTIONS.EDIT` that
15
+ * will be automatically translated when displayed on the UI or a pre-translated string, e.g. `Edit`.
16
+ * Equivalent to a normal string in usage and functionality.
17
+ */
18
+ type TranslatableString = string & Translatable;
19
+
20
+ export type { TranslatableString };
@@ -1,12 +0,0 @@
1
- import { SiTranslateService, SiTranslateServiceBuilder } from '@siemens/element-translate-ng/translate';
2
- import * as i0 from "@angular/core";
3
- /**
4
- * Similar to the no-translate builder, but this one is not initializing the Element version of $localize,
5
- * as it will be provided by angular.
6
- */
7
- export declare class SiTranslateNgLocalizeServiceBuilder extends SiTranslateServiceBuilder {
8
- private siTranslateNgService;
9
- buildService(): SiTranslateService;
10
- static ɵfac: i0.ɵɵFactoryDeclaration<SiTranslateNgLocalizeServiceBuilder, never>;
11
- static ɵprov: i0.ɵɵInjectableDeclaration<SiTranslateNgLocalizeServiceBuilder>;
12
- }
@@ -1,10 +0,0 @@
1
- import * as i0 from "@angular/core";
2
- /**
3
- * This module configures Element to work with \@angular/localize.
4
- * It should only be imported once in an application's root module (typically `app.module.ts`)
5
- */
6
- export declare class SiTranslateNgLocalizeModule {
7
- static ɵfac: i0.ɵɵFactoryDeclaration<SiTranslateNgLocalizeModule, never>;
8
- static ɵmod: i0.ɵɵNgModuleDeclaration<SiTranslateNgLocalizeModule, never, never, never>;
9
- static ɵinj: i0.ɵɵInjectorDeclaration<SiTranslateNgLocalizeModule>;
10
- }
@@ -1,10 +0,0 @@
1
- /**
2
- * Copyright (c) Siemens 2016 - 2025
3
- * SPDX-License-Identifier: MIT
4
- */
5
- import { EnvironmentProviders, Provider } from '@angular/core';
6
- /**
7
- * This provider configures Element to work with \@angular/localize.
8
- * It should only be imported once in an application's configuration (typically `app.config.ts`)
9
- */
10
- export declare const provideNgLocalizeForElement: () => (EnvironmentProviders | Provider)[];
@@ -1,7 +0,0 @@
1
- import { SiNoTranslateService } from '@siemens/element-translate-ng/translate';
2
- import * as i0 from "@angular/core";
3
- export declare class SiTranslateNgLocalizeService extends SiNoTranslateService {
4
- prevent$LocalizeInit: boolean;
5
- static ɵfac: i0.ɵɵFactoryDeclaration<SiTranslateNgLocalizeService, never>;
6
- static ɵprov: i0.ɵɵInjectableDeclaration<SiTranslateNgLocalizeService>;
7
- }
@@ -1,10 +0,0 @@
1
- import * as i0 from "@angular/core";
2
- /**
3
- * This module configures Element to use ngx-translate for translating {@link TranslatableString}
4
- * It should only be imported once in an applications root module (typically `app.module.ts`)
5
- */
6
- export declare class SiTranslateNgxTModule {
7
- static ɵfac: i0.ɵɵFactoryDeclaration<SiTranslateNgxTModule, never>;
8
- static ɵmod: i0.ɵɵNgModuleDeclaration<SiTranslateNgxTModule, never, never, never>;
9
- static ɵinj: i0.ɵɵInjectorDeclaration<SiTranslateNgxTModule>;
10
- }
@@ -1,10 +0,0 @@
1
- /**
2
- * Copyright (c) Siemens 2016 - 2025
3
- * SPDX-License-Identifier: MIT
4
- */
5
- import { EnvironmentProviders, Provider } from '@angular/core';
6
- /**
7
- * This provider configures Element to use ngx-translate for translating {@link TranslatableString}
8
- * It should only be imported once in an application's configuration (typically `app.config.ts`)
9
- */
10
- export declare const provideNgxTranslateForElement: () => (EnvironmentProviders | Provider)[];
@@ -1,19 +0,0 @@
1
- /**
2
- * Copyright (c) Siemens 2016 - 2025
3
- * SPDX-License-Identifier: MIT
4
- */
5
- import { Injector } from '@angular/core';
6
- import { SiTranslateService, SiTranslateServiceBuilder } from '@siemens/element-translate-ng/translate';
7
- import * as i0 from "@angular/core";
8
- /**
9
- * Builds {@link SiTranslateNgxTService} for each {@link TranslateService}.
10
- * The builder will create a new Service if a new {@link TranslateService} is found to support the isolated mode.
11
- *
12
- * @internal
13
- */
14
- export declare class SiTranslateNgxTServiceBuilder extends SiTranslateServiceBuilder {
15
- private serviceCache;
16
- buildService(injector: Injector): SiTranslateService;
17
- static ɵfac: i0.ɵɵFactoryDeclaration<SiTranslateNgxTServiceBuilder, never>;
18
- static ɵprov: i0.ɵɵInjectableDeclaration<SiTranslateNgxTServiceBuilder>;
19
- }
@@ -1,28 +0,0 @@
1
- import { TranslateService } from '@ngx-translate/core';
2
- import { SiTranslateService, TranslationResult } from '@siemens/element-translate-ng/translate';
3
- import { Observable } from 'rxjs';
4
- import * as i0 from "@angular/core";
5
- /**
6
- * {@link SiTranslateService} wrapper around ngx-translate
7
- *
8
- * @internal
9
- */
10
- export declare class SiTranslateNgxTService extends SiTranslateService {
11
- private ngxTranslateService;
12
- private defaultTranslations;
13
- private originalMissingHandler;
14
- constructor(ngxTranslateService: TranslateService);
15
- get currentLanguage(): string;
16
- get availableLanguages(): string[];
17
- set availableLanguages(languages: string[]);
18
- setCurrentLanguage(lang: string): Observable<void>;
19
- getDefaultLanguage(): string;
20
- setDefaultLanguage(lang: string): void;
21
- translate<T extends string | string[]>(keys: T, params?: Record<string, unknown>): Observable<TranslationResult<T>> | TranslationResult<T>;
22
- translateAsync<T extends string | string[]>(keys: T, params?: Record<string, unknown>): Observable<TranslationResult<T>>;
23
- translateSync<T extends string | string[]>(keys: T, params?: Record<string, unknown>): TranslationResult<T>;
24
- setTranslation(key: string, value: string): void;
25
- private handleMissingTranslation;
26
- static ɵfac: i0.ɵɵFactoryDeclaration<SiTranslateNgxTService, never>;
27
- static ɵprov: i0.ɵɵInjectableDeclaration<SiTranslateNgxTService>;
28
- }
package/public-api.d.ts DELETED
@@ -1,8 +0,0 @@
1
- /**
2
- * Copyright (c) Siemens 2016 - 2025
3
- * SPDX-License-Identifier: MIT
4
- */
5
- export * from '@siemens/element-translate-ng/angular-localize';
6
- export * from '@siemens/element-translate-ng/ngx-translate';
7
- export * from '@siemens/element-translate-ng/translate';
8
- export * from '@siemens/element-translate-ng/translate-types';
@@ -1,8 +0,0 @@
1
- /**
2
- * This var provides access to the global scope object based on the current runtime.
3
- * On Browser its is the window, on Node.js it is global.
4
- *
5
- * Whenever possible, inject(DOCUMENT) is preferred over this approach.
6
- */
7
- declare let globalScope: any;
8
- export { globalScope };
@@ -1,2 +0,0 @@
1
- /** @deprecated $localize is now automatically initialized. Drop all calls of this function. */
2
- export declare const initSiLocalize: () => void;
@@ -1,14 +0,0 @@
1
- import { SiTranslateService } from './si-translate.service';
2
- import { SiTranslateServiceBuilder } from './si-translate.service-builder';
3
- import * as i0 from "@angular/core";
4
- /**
5
- * Always returns the same instance of {@link SiNoTranslateService}
6
- *
7
- * @internal
8
- */
9
- export declare class SiNoTranslateServiceBuilder extends SiTranslateServiceBuilder {
10
- private siNoTranslateService;
11
- buildService(): SiTranslateService;
12
- static ɵfac: i0.ɵɵFactoryDeclaration<SiNoTranslateServiceBuilder, never>;
13
- static ɵprov: i0.ɵɵInjectableDeclaration<SiNoTranslateServiceBuilder>;
14
- }
@@ -1,21 +0,0 @@
1
- import { Observable } from 'rxjs';
2
- import { SiTranslateService, TranslationResult } from './si-translate.service';
3
- import * as i0 from "@angular/core";
4
- /**
5
- * Pass through implementation of the {@link SiTranslateService} which is used as a default.
6
- *
7
- * @internal
8
- */
9
- export declare class SiNoTranslateService extends SiTranslateService {
10
- get currentLanguage(): string;
11
- get availableLanguages(): string[];
12
- set availableLanguages(lang: string[]);
13
- setCurrentLanguage(lang: string): Observable<void>;
14
- getDefaultLanguage(): string;
15
- setDefaultLanguage(lang: string): void;
16
- translate<T extends string | string[]>(keys: T, _params?: Record<string, unknown>): TranslationResult<T>;
17
- translateSync<T extends string | string[]>(keys: T, params?: Record<string, unknown>): TranslationResult<T>;
18
- translateAsync<T extends string | string[]>(keys: T, params?: Record<string, unknown>): Observable<TranslationResult<T>>;
19
- static ɵfac: i0.ɵɵFactoryDeclaration<SiNoTranslateService, never>;
20
- static ɵprov: i0.ɵɵInjectableDeclaration<SiNoTranslateService>;
21
- }
@@ -1,6 +0,0 @@
1
- /**
2
- * Copyright (c) Siemens 2016 - 2025
3
- * SPDX-License-Identifier: MIT
4
- */
5
- import { InjectionToken } from '@angular/core';
6
- export declare const SI_TRANSLATABLE_VALUES: InjectionToken<Record<string, string>[]>;
@@ -1,11 +0,0 @@
1
- import { TranslatableString } from '@siemens/element-translate-ng/translate-types';
2
- import * as i0 from "@angular/core";
3
- export declare class SiTranslatableService {
4
- private readonly translatableValues;
5
- private readonly isNoTranslate;
6
- private readonly siTranslateService;
7
- constructor();
8
- resolveText(key: string, originalText: string): TranslatableString;
9
- static ɵfac: i0.ɵɵFactoryDeclaration<SiTranslatableService, never>;
10
- static ɵprov: i0.ɵɵInjectableDeclaration<SiTranslatableService>;
11
- }
@@ -1,2 +0,0 @@
1
- import { SiTranslateService } from './si-translate.service';
2
- export declare const injectSiTranslateService: () => SiTranslateService;
@@ -1,16 +0,0 @@
1
- import * as i0 from "@angular/core";
2
- import * as i1 from "./si-translate.pipe";
3
- /**
4
- * This provides declares SiTranslatePipe and provides a respective SiTranslateService.
5
- * It should be used internally of Element but NOT by any application.
6
- *
7
- * @deprecated This module is no longer needed.
8
- * Replace it with the {@link SiTranslatePipe} if needed, otherwise drop it without replacement.
9
- *
10
- * @internal
11
- */
12
- export declare class SiTranslateModule {
13
- static ɵfac: i0.ɵɵFactoryDeclaration<SiTranslateModule, never>;
14
- static ɵmod: i0.ɵɵNgModuleDeclaration<SiTranslateModule, never, [typeof i1.SiTranslatePipe], [typeof i1.SiTranslatePipe]>;
15
- static ɵinj: i0.ɵɵInjectorDeclaration<SiTranslateModule>;
16
- }
@@ -1,30 +0,0 @@
1
- /**
2
- * Copyright (c) Siemens 2016 - 2025
3
- * SPDX-License-Identifier: MIT
4
- */
5
- import { OnDestroy, PipeTransform } from '@angular/core';
6
- import * as i0 from "@angular/core";
7
- /**
8
- * Translates keys by using the {@link SiTranslateService}.
9
- * Within Element this pipe should be used instead of ngx-translates `translate` pipe.
10
- * Outside Element, this pipe should NOT be used.
11
- *
12
- * @internal
13
- */
14
- export declare class SiTranslatePipe implements PipeTransform, OnDestroy {
15
- private lastKeyParams?;
16
- private value;
17
- private subscription?;
18
- private siTranslateService;
19
- private cdRef;
20
- /**
21
- * Method which is called on any data passed to the pipe.
22
- * Called by Angular, should not be called directly.
23
- */
24
- transform(key: string, params?: any): string;
25
- transform(key: string | null | undefined, params?: any): string | null | undefined;
26
- ngOnDestroy(): void;
27
- private updateValue;
28
- static ɵfac: i0.ɵɵFactoryDeclaration<SiTranslatePipe, never>;
29
- static ɵpipe: i0.ɵɵPipeDeclaration<SiTranslatePipe, "translate", true>;
30
- }
@@ -1,21 +0,0 @@
1
- /**
2
- * Copyright (c) Siemens 2016 - 2025
3
- * SPDX-License-Identifier: MIT
4
- */
5
- import { Injector } from '@angular/core';
6
- import { SiTranslateService } from './si-translate.service';
7
- import * as i0 from "@angular/core";
8
- /**
9
- * Provide this class to build a custom translation service.
10
- *
11
- * @internal
12
- */
13
- export declare abstract class SiTranslateServiceBuilder {
14
- /**
15
- * Returns a translation service instance.
16
- * @param injector - Is used to retrieve dependencies needed to create the translation service.
17
- */
18
- abstract buildService(injector: Injector): SiTranslateService;
19
- static ɵfac: i0.ɵɵFactoryDeclaration<SiTranslateServiceBuilder, never>;
20
- static ɵprov: i0.ɵɵInjectableDeclaration<SiTranslateServiceBuilder>;
21
- }
@@ -1,98 +0,0 @@
1
- import { Observable } from 'rxjs';
2
- import * as i0 from "@angular/core";
3
- export type TranslationResult<T> = T extends string ? string : Record<string, string>;
4
- /**
5
- * @returns The culture language code of the browser, e.g. "en-US".
6
- */
7
- export declare const getBrowserCultureLanguage: () => string | undefined;
8
- /**
9
- * @returns The language code of the browser, e.g. "en".
10
- */
11
- export declare const getBrowserLanguage: () => string | undefined;
12
- /**
13
- * Wrapper around an actual translation framework which is meant to be used internally by Element.
14
- * Applications must not use this service.
15
- *
16
- * Use {@link injectSiTranslateService} to get an instance of the translation service.
17
- *
18
- * @internal
19
- */
20
- export declare abstract class SiTranslateService {
21
- protected translationChange$: Observable<void>;
22
- private documentRef;
23
- prevent$LocalizeInit?: boolean;
24
- /**
25
- * The currently used language.
26
- */
27
- abstract get currentLanguage(): string;
28
- /**
29
- * Sets a new language to be used. If needed, loads the language file.
30
- * @param lang - The language to be used.
31
- * @returns An observable that emits when the new language is loaded and activated.
32
- */
33
- abstract setCurrentLanguage(lang: string): Observable<void>;
34
- /**
35
- * The language to be used as default.
36
- * @param lang - The language code.
37
- */
38
- abstract setDefaultLanguage(lang: string): void;
39
- /**
40
- * The language to be used as default.
41
- * @returns The code of the default language.
42
- */
43
- abstract getDefaultLanguage(): string;
44
- /**
45
- * The available languages.
46
- */
47
- abstract get availableLanguages(): string[];
48
- abstract set availableLanguages(languages: string[]);
49
- /**
50
- * If the underlying translation library supports switching the language
51
- * and/or updating the translation texts, this observable will emit.
52
- * There is no initial emit.
53
- */
54
- get translationChange(): Observable<void>;
55
- /**
56
- * Translates the key(s) by using the underlying translation library.
57
- *
58
- * @param keys - A single translation key or an array of keys.
59
- * @param params - Parameters to be replaced within the translation text.
60
- *
61
- * @returns Returns the translated key or an object with the translated keys.
62
- * Depending on the underlying translation library (sync/async) the result will
63
- * be wrapped in an Observable.
64
- */
65
- abstract translate<T extends string | string[]>(keys: T, params?: Record<string, unknown>): Observable<TranslationResult<T>> | TranslationResult<T>;
66
- /**
67
- * Translates the key(s) by using the underlying translation library in an asynchronous manner.
68
- * It will emit each time the active language is changed.
69
- *
70
- * @param keys - A single translation key or an array of keys.
71
- * @param params - Parameters to be replaced within the translation text.
72
- *
73
- * @returns Returns the translated key or an object with the translated keys wrapped in an Observable.
74
- */
75
- abstract translateAsync<T extends string | string[]>(keys: T, params?: Record<string, unknown>): Observable<TranslationResult<T>>;
76
- /**
77
- * Translates the key(s) by using the underlying translation library in a synchronous manner.
78
- *
79
- * Warning: The caller of this function needs to make sure the translation file(s) are already loaded.
80
- * It is generally not recommended to use this function unless you know exactly what you are doing.
81
- *
82
- * @param keys - A single translation key or an array of keys.
83
- * @param params - Parameters to be replaced within the translation text.
84
- *
85
- * @returns Returns the translated key or an object with the translated keys.
86
- */
87
- abstract translateSync<T extends string | string[]>(keys: T, params?: Record<string, unknown>): TranslationResult<T>;
88
- /**
89
- * If supported by the underlying translation library, this method can be used to add a translation for a specific key.
90
- * It is intended to be used for adding the english default value.
91
- * It will be called whenever a key within element is resolved.
92
- * An implementation of this method must check that it does not override an existing translation.
93
- */
94
- setTranslation?(key: string, value: string): void;
95
- setDocumentLanguage(lang: string): void;
96
- static ɵfac: i0.ɵɵFactoryDeclaration<SiTranslateService, never>;
97
- static ɵprov: i0.ɵɵInjectableDeclaration<SiTranslateService>;
98
- }
@@ -1,7 +0,0 @@
1
- /**
2
- * Copyright (c) Siemens 2016 - 2025
3
- * SPDX-License-Identifier: MIT
4
- */
5
- import { Injector, Provider } from '@angular/core';
6
- import { SiTranslateService } from '../si-translate.service';
7
- export declare const provideMockTranslateServiceBuilder: (buildService: (injector: Injector) => SiTranslateService) => Provider;
@@ -1,19 +0,0 @@
1
- /**
2
- * Copyright (c) Siemens 2016 - 2025
3
- * SPDX-License-Identifier: MIT
4
- */
5
- /**
6
- * Empty interface to represent translatable strings before they are translated.
7
- * Needed so the TypeScript compiler doesn't strip away the {@link TranslatableString} type.
8
- * Ignored by the documentation.
9
- * @internal
10
- */
11
- interface Translatable {
12
- }
13
- /**
14
- * Represents a translatable string. This can either be a translation key, e.g. `ACTIONS.EDIT` that
15
- * will be automatically translated when displayed on the UI or a pre-translated string, e.g. `Edit`.
16
- * Equivalent to a normal string in usage and functionality.
17
- */
18
- export type TranslatableString = string & Translatable;
19
- export {};