@sixbell-telco/sdk 4.6.1 → 4.7.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.
- package/CHANGELOG.md +32 -0
- package/fesm2022/sixbell-telco-sdk-utils-mfe.mjs +5 -14
- package/fesm2022/sixbell-telco-sdk-utils-mfe.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-utils-runtime-config.mjs +15 -3
- package/fesm2022/sixbell-telco-sdk-utils-runtime-config.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-utils-translation-testing.mjs +5 -1
- package/fesm2022/sixbell-telco-sdk-utils-translation-testing.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-utils-translation.mjs +358 -129
- package/fesm2022/sixbell-telco-sdk-utils-translation.mjs.map +1 -1
- package/manifest.json +1 -1
- package/package.json +1 -1
- package/utils/mfe/README.md +1 -1
- package/utils/mfe/src/provide-mfe-shadow-shell.d.ts +5 -1
- package/utils/runtime-config/src/http-client.d.ts +7 -0
- package/utils/translation/README.md +9 -5
- package/utils/translation/src/title-strategy/translated-title-strategy.d.ts +9 -0
- package/utils/translation/src/translation.service.d.ts +81 -6
- package/utils/translation/testing/src/translation-testing.d.ts +2 -0
|
@@ -18,14 +18,28 @@ export declare class TranslationService {
|
|
|
18
18
|
private translationHttpClient;
|
|
19
19
|
private hasAppliedInitialLanguage;
|
|
20
20
|
private isUsingFallbackConfig;
|
|
21
|
-
private prefetchLanguages;
|
|
22
21
|
private isApplyingRuntimeConfig;
|
|
23
22
|
private bundleRefreshId;
|
|
24
23
|
private readonly inactiveRefreshIds;
|
|
24
|
+
/** The last config passed to `configure()`, before the paths added with `addTranslationPaths()`. */
|
|
25
|
+
private baseConfig;
|
|
26
|
+
/** Paths added at runtime (e.g. a federated remote's i18n folder); every applied config keeps them. */
|
|
27
|
+
private readonly addedPaths;
|
|
28
|
+
/** Bumped whenever the translation paths change, so a load started with older paths fetches again. */
|
|
29
|
+
private pathsEpoch;
|
|
30
|
+
/** Languages this service loaded, set or asked ngx-translate to load: the ones a refresh must update. */
|
|
31
|
+
private readonly knownLanguages;
|
|
32
|
+
/** Languages whose last load had a file that could not be read; they are fetched again on next use. */
|
|
33
|
+
private readonly incompleteLanguages;
|
|
34
|
+
/** The latest runtime refresh, so `addTranslationPaths()` resolves only when its paths are applied. */
|
|
35
|
+
private latestRefresh;
|
|
36
|
+
/** The first `setRuntimeConfig()` while it runs, so paths added meanwhile can wait for it. */
|
|
37
|
+
private firstLoad;
|
|
38
|
+
/** Bundles the SDK loader read in full (every file answered, paths unchanged): they replace a language. */
|
|
39
|
+
private readonly completeBundles;
|
|
25
40
|
private runtimeHash;
|
|
26
41
|
private runtimeLoader?;
|
|
27
42
|
private runtimeMeta?;
|
|
28
|
-
private pendingUpdatedLanguages;
|
|
29
43
|
private bootstrapValidated;
|
|
30
44
|
private readonly translationTick;
|
|
31
45
|
private readonly localeConfig;
|
|
@@ -41,14 +55,56 @@ export declare class TranslationService {
|
|
|
41
55
|
constructor();
|
|
42
56
|
configure(config: TranslationConfig): void;
|
|
43
57
|
private resolveStoredLanguage;
|
|
58
|
+
/** The config's paths (or the defaults) followed by the runtime-added paths it does not list. */
|
|
59
|
+
private withAddedPaths;
|
|
60
|
+
/** Sets the translation paths; returns `true` when they changed. */
|
|
61
|
+
private updatePaths;
|
|
44
62
|
private reloadForNewPaths;
|
|
63
|
+
/**
|
|
64
|
+
* Adds translation folders at runtime, e.g. a federated remote's `/<mount>/assets/i18n/` when its
|
|
65
|
+
* routes load. The paths stay in every config applied afterwards (runtime refreshes included), and
|
|
66
|
+
* every language already loaded is fetched again with them: the active language and the loaded
|
|
67
|
+
* fallback before this resolves, the others in the background. Languages never loaded keep loading
|
|
68
|
+
* lazily, with all the paths, on first use. Calling it again with paths already added fetches the
|
|
69
|
+
* languages whose last load had a file that could not be read, so a remote that failed is retried.
|
|
70
|
+
*/
|
|
71
|
+
addTranslationPaths(paths: readonly string[]): Promise<void>;
|
|
72
|
+
private trackRefresh;
|
|
73
|
+
/** Waits until no newer refresh superseded the one being awaited. */
|
|
74
|
+
private settleRefreshes;
|
|
75
|
+
private retryIncompleteLanguages;
|
|
45
76
|
/**
|
|
46
77
|
* Applies a runtime config. On the first load `ready()` stays false until the bundle is in. Once
|
|
47
78
|
* translations are ready, a refresh (e.g. a host adding a remote's i18n path) fetches the new bundle
|
|
48
79
|
* first and merges it over the loaded one, so `ready()` and the visible translations never drop.
|
|
49
80
|
*/
|
|
50
81
|
setRuntimeConfig(config: TranslationConfig): Promise<void>;
|
|
82
|
+
private loadFirstConfig;
|
|
83
|
+
/**
|
|
84
|
+
* Waits for the fallback language when it differs from the active one, so a key missing in the
|
|
85
|
+
* active language resolves from the fallback on first paint instead of showing the key.
|
|
86
|
+
*/
|
|
87
|
+
private waitForFallbackLanguage;
|
|
88
|
+
/** Languages loaded in ngx-translate (or loading through this service). */
|
|
89
|
+
private loadedLanguages;
|
|
90
|
+
/**
|
|
91
|
+
* Which languages a refresh fetches again: the active language and the loaded fallback are awaited;
|
|
92
|
+
* every other loaded language that is still available is refreshed in the background. A language
|
|
93
|
+
* never loaded is left alone: ngx-translate loads it with the current paths on first use.
|
|
94
|
+
*/
|
|
95
|
+
private planRefresh;
|
|
96
|
+
/** Merges each fetched bundle into its language; returns `true` when at least one was merged. */
|
|
97
|
+
private mergeBundles;
|
|
51
98
|
private refreshRuntimeConfig;
|
|
99
|
+
/** Refreshes every loaded language after the paths changed outside a runtime config (`configure()`). */
|
|
100
|
+
private refreshLoadedBundles;
|
|
101
|
+
private refreshInBackground;
|
|
102
|
+
/**
|
|
103
|
+
* Fetches one language and merges it (the latest fetch per language wins). When it is the active or
|
|
104
|
+
* the fallback language, `onLangChange`, `changes()` and `onLanguageChange` tick so views built from
|
|
105
|
+
* them (menus, labels) pick the new keys up.
|
|
106
|
+
*/
|
|
107
|
+
private refreshLanguageInBackground;
|
|
52
108
|
private refreshLoadedLanguage;
|
|
53
109
|
/**
|
|
54
110
|
* Re-selects the refreshed active language so `onLangChange` fires once, as it did when a refresh
|
|
@@ -62,14 +118,25 @@ export declare class TranslationService {
|
|
|
62
118
|
* previous values until the caller merges the result, and a failed fetch returns `null`.
|
|
63
119
|
*/
|
|
64
120
|
private fetchBundle;
|
|
121
|
+
/**
|
|
122
|
+
* Stores a refreshed bundle. A bundle the SDK loader read in full replaces the language, so a key
|
|
123
|
+
* removed from a file goes away without a reload; any other bundle (a file failed, or a custom loader)
|
|
124
|
+
* is merged over the loaded one, so the keys of a file that could not be read are kept.
|
|
125
|
+
*/
|
|
126
|
+
private applyBundle;
|
|
127
|
+
/** Fetches `lang` for a refresh that awaits it; an older background fetch of `lang` landing later is dropped. */
|
|
128
|
+
private fetchAwaitedBundle;
|
|
129
|
+
/** Fetches and merges `lang`; only the latest fetch per language is applied. Returns `true` when merged. */
|
|
65
130
|
private swapTranslations;
|
|
66
131
|
private notifyTranslationsChanged;
|
|
132
|
+
/**
|
|
133
|
+
* @deprecated No effect. Languages load on first use with every translation path, and a refresh
|
|
134
|
+
* updates the languages already loaded; the old prefetch downloaded files without keeping them.
|
|
135
|
+
*/
|
|
67
136
|
enablePrefetch(enable: boolean): void;
|
|
68
|
-
|
|
69
|
-
private prefetchRemainingLanguages;
|
|
70
|
-
private loadLanguageResources;
|
|
71
|
-
private queueUpdatedLanguage;
|
|
137
|
+
/** Refreshes the given languages that are loaded and available; the others load on first use. */
|
|
72
138
|
private reloadLanguages;
|
|
139
|
+
/** Fetches again every loaded language except the active one. Languages never loaded are not requested. */
|
|
73
140
|
refreshInactiveLanguages(): Promise<void>;
|
|
74
141
|
private validateBootstrapCache;
|
|
75
142
|
private initializeFromStorage;
|
|
@@ -79,6 +146,7 @@ export declare class TranslationService {
|
|
|
79
146
|
getCurrentLocale(): string;
|
|
80
147
|
getLocaleConfig(): TranslationLocaleConfig;
|
|
81
148
|
resolveLocale(language?: string | null): string;
|
|
149
|
+
/** The configured language codes (as `getAvailableLanguageCodes()`), not only the ones loaded so far. */
|
|
82
150
|
getAvailableLanguages(): string[];
|
|
83
151
|
getDefaultLanguage(): string;
|
|
84
152
|
instant(key: string, params?: object | undefined): string;
|
|
@@ -98,7 +166,14 @@ export declare class TranslationService {
|
|
|
98
166
|
refreshTranslation(loader?: RuntimeConfigLoader<TranslationConfig>): Promise<void>;
|
|
99
167
|
withTranslationsReady<T>(fn: () => T): T | undefined;
|
|
100
168
|
private getOrCreateHttpClient;
|
|
169
|
+
/** Reads one language file. A 404 is a file that does not exist (empty, not a failure). */
|
|
101
170
|
private fetchTranslation;
|
|
171
|
+
/**
|
|
172
|
+
* Loads one language from every translation path and merges the files in path order. When the paths
|
|
173
|
+
* change while it fetches (e.g. a remote's folder is added), it fetches again with the new paths, so
|
|
174
|
+
* ngx-translate, which stores a load result over the language, never keeps a bundle missing them.
|
|
175
|
+
*/
|
|
176
|
+
private loadLanguageBundle;
|
|
102
177
|
createTranslateLoader(): TranslateLoader;
|
|
103
178
|
private isTranslationObject;
|
|
104
179
|
private deepMergeTranslations;
|
|
@@ -51,7 +51,9 @@ export declare class FakeTranslationService implements TranslationServiceApi {
|
|
|
51
51
|
constructor();
|
|
52
52
|
configure(config: TranslationConfig): void;
|
|
53
53
|
setRuntimeConfig(config: TranslationConfig): Promise<void>;
|
|
54
|
+
/** @deprecated No effect, as in `TranslationService`. */
|
|
54
55
|
enablePrefetch(): void;
|
|
56
|
+
addTranslationPaths(): Promise<void>;
|
|
55
57
|
refreshInactiveLanguages(): Promise<void>;
|
|
56
58
|
setLanguage(lang: string): void;
|
|
57
59
|
getCurrentLanguage(): string;
|