@taon-dev/i18n 21.0.49 → 21.0.51
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/VERIFIED-BUILD-DATA.jsonc +3 -3
- package/browser/fesm2022/i18n-browser.mjs +88 -6
- package/browser/fesm2022/i18n-browser.mjs.map +1 -1
- package/browser/package.json +1 -1
- package/browser/types/i18n-browser.d.ts +11 -26
- package/browser-prod/fesm2022/i18n-browser-prod.mjs +88 -6
- package/browser-prod/fesm2022/i18n-browser-prod.mjs.map +1 -1
- package/browser-prod/package.json +1 -1
- package/browser-prod/types/i18n-browser-prod.d.ts +11 -26
- package/full-dts/build-info._auto-generated_.d.ts +1 -1
- package/full-dts/index._auto-generated_.d.ts +1 -2
- package/full-dts/local-translation.d.ts +8 -1
- package/lib/build-info._auto-generated_.d.ts +1 -1
- package/lib/build-info._auto-generated_.js +1 -1
- package/lib/index._auto-generated_.d.ts +0 -1
- package/lib/index._auto-generated_.js +0 -1
- package/lib/index._auto-generated_.js.map +1 -1
- package/lib/local-translation.d.ts +8 -1
- package/lib/local-translation.js +90 -6
- package/lib/local-translation.js.map +1 -1
- package/lib/package.json +1 -1
- package/lib-esm/lib/build-info._auto-generated_.d.ts +1 -1
- package/lib-esm/lib/build-info._auto-generated_.js +1 -1
- package/lib-esm/lib/index._auto-generated_.d.ts +0 -1
- package/lib-esm/lib/index._auto-generated_.js +0 -1
- package/lib-esm/lib/index._auto-generated_.js.map +1 -1
- package/lib-esm/lib/local-translation.d.ts +8 -1
- package/lib-esm/lib/local-translation.js +90 -8
- package/lib-esm/lib/local-translation.js.map +1 -1
- package/lib-prod/build-info._auto-generated_.d.ts +1 -1
- package/lib-prod/build-info._auto-generated_.js +1 -1
- package/lib-prod/index._auto-generated_.d.ts +0 -1
- package/lib-prod/index._auto-generated_.js +0 -1
- package/lib-prod/index._auto-generated_.js.map +1 -1
- package/lib-prod/local-translation.d.ts +8 -1
- package/lib-prod/local-translation.js +90 -6
- package/lib-prod/local-translation.js.map +1 -1
- package/lib-prod/package.json +1 -1
- package/package.json +1 -1
- package/ts-source/browser-code/build-info._auto-generated_.ts +9 -4
- package/ts-source/browser-code/i18n/lib.translation.ts +8 -3
- package/ts-source/browser-code/i18n/translation.ts.en-US.i18n.data.ts +8 -3
- package/ts-source/browser-code/i18n/translation.ts.pl-PL.i18n.data.ts +8 -3
- package/ts-source/browser-code/index._auto-generated_.ts +8 -4
- package/ts-source/browser-code/index.scss +8 -3
- package/ts-source/browser-code/index.ts +8 -3
- package/ts-source/browser-code/local-translation.ts +40 -3
- package/ts-source/browser-code/start-cli.ts +8 -3
- package/ts-source/browser-code/translate.directive.ts +8 -3
- package/ts-source/browser-code/translate.pipe.ts +8 -3
- package/ts-source/browser-code/translate.service.ts +8 -3
- package/ts-source/browser-code/translation-manager.ts +8 -3
- package/ts-source/browser-code/translation.models.ts +8 -3
- package/ts-source/browser-code/translation.ts +8 -3
- package/ts-source/browser-code/utils-i18n-extract-gettext-translate-from-html.ts +8 -3
- package/ts-source/browser-code/utils-i18n-html.ts +8 -3
- package/ts-source/browser-code/utils-po-file.ts +8 -3
- package/ts-source/browser-code-prod/build-info._auto-generated_.ts +9 -4
- package/ts-source/browser-code-prod/i18n/lib.translation.ts +8 -3
- package/ts-source/browser-code-prod/i18n/translation.ts.en-US.i18n.data.ts +8 -3
- package/ts-source/browser-code-prod/i18n/translation.ts.pl-PL.i18n.data.ts +8 -3
- package/ts-source/browser-code-prod/index._auto-generated_.ts +8 -4
- package/ts-source/browser-code-prod/index.scss +8 -3
- package/ts-source/browser-code-prod/index.ts +8 -3
- package/ts-source/browser-code-prod/local-translation.ts +40 -3
- package/ts-source/browser-code-prod/start-cli.ts +8 -3
- package/ts-source/browser-code-prod/translate.directive.ts +8 -3
- package/ts-source/browser-code-prod/translate.pipe.ts +8 -3
- package/ts-source/browser-code-prod/translate.service.ts +8 -3
- package/ts-source/browser-code-prod/translation-manager.ts +8 -3
- package/ts-source/browser-code-prod/translation.models.ts +8 -3
- package/ts-source/browser-code-prod/translation.ts +8 -3
- package/ts-source/browser-code-prod/utils-i18n-extract-gettext-translate-from-html.ts +8 -3
- package/ts-source/browser-code-prod/utils-i18n-html.ts +8 -3
- package/ts-source/browser-code-prod/utils-po-file.ts +8 -3
- package/ts-source/websql-code/build-info._auto-generated_.ts +9 -4
- package/ts-source/websql-code/i18n/lib.translation.ts +8 -3
- package/ts-source/websql-code/i18n/translation.ts.en-US.i18n.data.ts +8 -3
- package/ts-source/websql-code/i18n/translation.ts.pl-PL.i18n.data.ts +8 -3
- package/ts-source/websql-code/index._auto-generated_.ts +8 -4
- package/ts-source/websql-code/index.scss +8 -3
- package/ts-source/websql-code/index.ts +8 -3
- package/ts-source/websql-code/local-translation.ts +40 -3
- package/ts-source/websql-code/start-cli.ts +8 -3
- package/ts-source/websql-code/translate.directive.ts +8 -3
- package/ts-source/websql-code/translate.pipe.ts +8 -3
- package/ts-source/websql-code/translate.service.ts +8 -3
- package/ts-source/websql-code/translation-manager.ts +8 -3
- package/ts-source/websql-code/translation.models.ts +8 -3
- package/ts-source/websql-code/translation.ts +8 -3
- package/ts-source/websql-code/utils-i18n-extract-gettext-translate-from-html.ts +8 -3
- package/ts-source/websql-code/utils-i18n-html.ts +8 -3
- package/ts-source/websql-code/utils-po-file.ts +8 -3
- package/ts-source/websql-code-prod/build-info._auto-generated_.ts +9 -4
- package/ts-source/websql-code-prod/i18n/lib.translation.ts +8 -3
- package/ts-source/websql-code-prod/i18n/translation.ts.en-US.i18n.data.ts +8 -3
- package/ts-source/websql-code-prod/i18n/translation.ts.pl-PL.i18n.data.ts +8 -3
- package/ts-source/websql-code-prod/index._auto-generated_.ts +8 -4
- package/ts-source/websql-code-prod/index.scss +8 -3
- package/ts-source/websql-code-prod/index.ts +8 -3
- package/ts-source/websql-code-prod/local-translation.ts +40 -3
- package/ts-source/websql-code-prod/start-cli.ts +8 -3
- package/ts-source/websql-code-prod/translate.directive.ts +8 -3
- package/ts-source/websql-code-prod/translate.pipe.ts +8 -3
- package/ts-source/websql-code-prod/translate.service.ts +8 -3
- package/ts-source/websql-code-prod/translation-manager.ts +8 -3
- package/ts-source/websql-code-prod/translation.models.ts +8 -3
- package/ts-source/websql-code-prod/translation.ts +8 -3
- package/ts-source/websql-code-prod/utils-i18n-extract-gettext-translate-from-html.ts +8 -3
- package/ts-source/websql-code-prod/utils-i18n-html.ts +8 -3
- package/ts-source/websql-code-prod/utils-po-file.ts +8 -3
- package/websql/fesm2022/i18n-websql.mjs +88 -6
- package/websql/fesm2022/i18n-websql.mjs.map +1 -1
- package/websql/package.json +1 -1
- package/websql/types/i18n-websql.d.ts +11 -26
- package/websql-prod/fesm2022/i18n-websql-prod.mjs +88 -6
- package/websql-prod/fesm2022/i18n-websql-prod.mjs.map +1 -1
- package/websql-prod/package.json +1 -1
- package/websql-prod/types/i18n-websql-prod.d.ts +11 -26
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
|
-
import { UtilsI18n
|
|
2
|
+
import { UtilsI18n } from 'tnp-core/websql';
|
|
3
3
|
import * as i0 from '@angular/core';
|
|
4
4
|
import { ChangeDetectorRef, WritableSignal, AfterViewInit, OnChanges, PipeTransform, OnDestroy } from '@angular/core';
|
|
5
5
|
import * as rxjs from 'rxjs';
|
|
@@ -28,16 +28,22 @@ declare const CURRENT_PACKAGE_TAON_VERSION = "v21";
|
|
|
28
28
|
/**
|
|
29
29
|
* Autogenerated by current cli tool. Use *tnp release* to bump version.
|
|
30
30
|
*/
|
|
31
|
-
declare const CURRENT_PACKAGE_VERSION = "21.0.
|
|
31
|
+
declare const CURRENT_PACKAGE_VERSION = "21.0.51";
|
|
32
32
|
|
|
33
33
|
interface TranslationOptions {
|
|
34
34
|
text: string;
|
|
35
35
|
from: UtilsI18n.CommonLocaleCode;
|
|
36
36
|
to: UtilsI18n.CommonLocaleCode;
|
|
37
37
|
/**
|
|
38
|
-
* Nearby source-language text
|
|
38
|
+
* Nearby source-language text used only to give the translator
|
|
39
|
+
* additional context.
|
|
40
|
+
*
|
|
41
|
+
* Context is never returned from translate().
|
|
39
42
|
*/
|
|
40
43
|
context?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Source terms that should be replaced with specific translated terms.
|
|
46
|
+
*/
|
|
41
47
|
glossary?: Record<string, string>;
|
|
42
48
|
}
|
|
43
49
|
interface AiDownloadProgress {
|
|
@@ -94,6 +100,7 @@ declare class LocalTranslationService {
|
|
|
94
100
|
private warmupTranslator;
|
|
95
101
|
translate(options: TranslationOptions): Promise<string>;
|
|
96
102
|
private protectGlossary;
|
|
103
|
+
private protectInterpolation;
|
|
97
104
|
private getModelsCachePath;
|
|
98
105
|
}
|
|
99
106
|
|
|
@@ -256,27 +263,5 @@ declare namespace UtilsPoFile {
|
|
|
256
263
|
function mergeGettextFile(jsonContent1FromTsHtml: UtilsI18n.GettextFile, json2ContentFromPoFileModifedByUser?: UtilsI18n.GettextFile | null): UtilsI18n.GettextFile;
|
|
257
264
|
}
|
|
258
265
|
|
|
259
|
-
interface EnUsTraslationOverrideSrcLibTranslationTs {
|
|
260
|
-
"en-US": {
|
|
261
|
-
"": {
|
|
262
|
-
"amazing better place"?: string;
|
|
263
|
-
"asdasd"?: string;
|
|
264
|
-
"hello"?: string;
|
|
265
|
-
};
|
|
266
|
-
};
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
interface PlPlTraslationOverrideSrcLibTranslationTs {
|
|
270
|
-
"pl-PL": {
|
|
271
|
-
"": {
|
|
272
|
-
"amazing better place"?: string;
|
|
273
|
-
"asdasd"?: string;
|
|
274
|
-
"hello"?: string;
|
|
275
|
-
};
|
|
276
|
-
};
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
type LibOverride = CoreModels.DeepPartial<EnUsTraslationOverrideSrcLibTranslationTs | PlPlTraslationOverrideSrcLibTranslationTs>;
|
|
280
|
-
|
|
281
266
|
export { APP_ID, BUILD_BASE_HREF, BUILD_FRAMEWORK_CLI_NAME, CURRENT_PACKAGE_TAON_VERSION, CURRENT_PACKAGE_VERSION, LocalTranslationService, PROJECT_NPM_NAME, TranslateDirective, TranslatePipe, TranslateService, Translation, TranslationManager, UtilsI18nExtractGettextTranslateFromHtml, UtilsI18nHtml, UtilsPoFile, startCli };
|
|
282
|
-
export type { AiDownloadProgress,
|
|
267
|
+
export type { AiDownloadProgress, MakeSureAiDownloadedOptions, TaonTranslationsMap, TaonTranslationsMapImport, Translatable, TranslationBinding, TranslationLookup, TranslationOptions, TranslationParams };
|
|
@@ -28,26 +28,34 @@ const CURRENT_PACKAGE_TAON_VERSION = 'v21';
|
|
|
28
28
|
/**
|
|
29
29
|
* Autogenerated by current cli tool. Use *tnp release* to bump version.
|
|
30
30
|
*/
|
|
31
|
-
const CURRENT_PACKAGE_VERSION = '21.0.
|
|
31
|
+
const CURRENT_PACKAGE_VERSION = '21.0.51';
|
|
32
32
|
// THIS FILE IS GENERATED - DO NOT MODIFY
|
|
33
33
|
|
|
34
|
+
//#region imports
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region constants
|
|
34
37
|
const MODEL_ID = 'Xenova/nllb-200-distilled-600M';
|
|
35
38
|
const nllbLanguageCodes = {
|
|
36
39
|
'en-US': 'eng_Latn',
|
|
37
40
|
'pl-PL': 'pol_Latn',
|
|
38
41
|
'de-DE': 'deu_Latn',
|
|
39
42
|
};
|
|
43
|
+
const CONTEXT_SEPARATOR = '→';
|
|
44
|
+
//#endregion
|
|
40
45
|
class LocalTranslationService {
|
|
41
46
|
constructor() {
|
|
42
47
|
this.aiReady = false;
|
|
43
48
|
this.progressListeners = new Set();
|
|
49
|
+
//#endregion
|
|
44
50
|
}
|
|
51
|
+
//#endregion
|
|
45
52
|
/**
|
|
46
53
|
* Downloads, caches and loads the translation model.
|
|
47
54
|
*
|
|
48
55
|
* Multiple simultaneous calls share the same initialization promise.
|
|
49
56
|
* After this resolves, translate() reuses the already loaded model.
|
|
50
57
|
*/
|
|
58
|
+
//#region methods / make sure ai downloaded
|
|
51
59
|
async makeSureAiDownloaded(options = {}) {
|
|
52
60
|
/* */
|
|
53
61
|
/* */
|
|
@@ -69,12 +77,16 @@ class LocalTranslationService {
|
|
|
69
77
|
/* */
|
|
70
78
|
return (void 0);
|
|
71
79
|
}
|
|
80
|
+
//#endregion
|
|
72
81
|
/**
|
|
73
82
|
* True only in this process after pipeline initialization succeeded.
|
|
74
83
|
*/
|
|
84
|
+
//#region methods / is ai ready
|
|
75
85
|
isAiReady() {
|
|
76
86
|
return this.aiReady;
|
|
77
87
|
}
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region methods / get translator
|
|
78
90
|
getTranslator() {
|
|
79
91
|
this.translatorPromise ??= this.createTranslator().catch(error => {
|
|
80
92
|
// Allow a later call to retry after a network or disk failure.
|
|
@@ -84,6 +96,8 @@ class LocalTranslationService {
|
|
|
84
96
|
});
|
|
85
97
|
return this.translatorPromise;
|
|
86
98
|
}
|
|
99
|
+
//#endregion
|
|
100
|
+
//#region methods / create translator
|
|
87
101
|
async createTranslator() {
|
|
88
102
|
/* */
|
|
89
103
|
/* */
|
|
@@ -108,11 +122,11 @@ class LocalTranslationService {
|
|
|
108
122
|
/* */
|
|
109
123
|
/* */
|
|
110
124
|
/* */
|
|
111
|
-
/* */
|
|
112
|
-
/* */
|
|
113
125
|
return (void 0);
|
|
114
126
|
return void 0;
|
|
115
127
|
}
|
|
128
|
+
//#endregion
|
|
129
|
+
//#region methods / emit progress
|
|
116
130
|
emitProgress(progress) {
|
|
117
131
|
for (const listener of this.progressListeners) {
|
|
118
132
|
try {
|
|
@@ -123,6 +137,8 @@ class LocalTranslationService {
|
|
|
123
137
|
}
|
|
124
138
|
}
|
|
125
139
|
}
|
|
140
|
+
//#endregion
|
|
141
|
+
//#region methods / warmup translator
|
|
126
142
|
warmupTranslator(translator) {
|
|
127
143
|
this.warmupPromise ??= translator('Hello.', {
|
|
128
144
|
src_lang: 'eng_Latn',
|
|
@@ -136,6 +152,8 @@ class LocalTranslationService {
|
|
|
136
152
|
});
|
|
137
153
|
return this.warmupPromise;
|
|
138
154
|
}
|
|
155
|
+
//#endregion
|
|
156
|
+
//#region methods / translate
|
|
139
157
|
async translate(options) {
|
|
140
158
|
/* */
|
|
141
159
|
/* */
|
|
@@ -181,8 +199,46 @@ class LocalTranslationService {
|
|
|
181
199
|
/* */
|
|
182
200
|
/* */
|
|
183
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
|
+
/* */
|
|
184
238
|
return (void 0);
|
|
185
239
|
}
|
|
240
|
+
//#endregion
|
|
241
|
+
//#region methods / protect glossary
|
|
186
242
|
protectGlossary(text, glossary) {
|
|
187
243
|
if (!glossary || Object.keys(glossary).length === 0) {
|
|
188
244
|
return {
|
|
@@ -213,6 +269,35 @@ class LocalTranslationService {
|
|
|
213
269
|
},
|
|
214
270
|
};
|
|
215
271
|
}
|
|
272
|
+
//#endregion
|
|
273
|
+
//#region methods / protect interpolation
|
|
274
|
+
protectInterpolation(text) {
|
|
275
|
+
const replacements = [];
|
|
276
|
+
const preparedText = text.replace(/\[\[[\s\S]*?\]\]/g, originalValue => {
|
|
277
|
+
const placeholder = `[[${replacements.length}]]`;
|
|
278
|
+
replacements.push({
|
|
279
|
+
placeholder,
|
|
280
|
+
originalValue,
|
|
281
|
+
});
|
|
282
|
+
return placeholder;
|
|
283
|
+
});
|
|
284
|
+
return {
|
|
285
|
+
preparedText,
|
|
286
|
+
restore(translatedText) {
|
|
287
|
+
let result = translatedText;
|
|
288
|
+
for (const replacement of replacements) {
|
|
289
|
+
if (!result.includes(replacement.placeholder)) {
|
|
290
|
+
throw new Error(`Translation model removed interpolation placeholder ` +
|
|
291
|
+
`"${replacement.placeholder}" while translating "${text}".`);
|
|
292
|
+
}
|
|
293
|
+
result = result.replaceAll(replacement.placeholder, replacement.originalValue);
|
|
294
|
+
}
|
|
295
|
+
return result;
|
|
296
|
+
},
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
//#endregion
|
|
300
|
+
//#region methods / get models cache path
|
|
216
301
|
getModelsCachePath() {
|
|
217
302
|
const cachePath = crossPlatformPath([
|
|
218
303
|
UtilsOs__NS__getRealHomeDir(),
|
|
@@ -1931,9 +2016,6 @@ function unescapePoString(value) {
|
|
|
1931
2016
|
//#endregion
|
|
1932
2017
|
//end of namespace UtilsPoFile
|
|
1933
2018
|
|
|
1934
|
-
;
|
|
1935
|
-
// THIS FILE IS GENERATED - DO NOT MODIFY
|
|
1936
|
-
|
|
1937
2019
|
// @ts-nocheck
|
|
1938
2020
|
// This file is auto-generated during init process. Do not modify.
|
|
1939
2021
|
// This disable this auto generate file.
|