@taon-dev/i18n 21.0.27 → 21.0.33
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 +2 -2
- package/bin/start.js +1 -1
- package/browser/fesm2022/i18n-browser.mjs +220 -35
- package/browser/fesm2022/i18n-browser.mjs.map +1 -1
- package/browser/package.json +1 -1
- package/browser/types/i18n-browser.d.ts +73 -11
- package/browser-prod/fesm2022/i18n-browser-prod.mjs +220 -35
- 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 +73 -11
- package/html/assets/generated/pwa/html-pwa.html +53 -53
- 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 +1 -0
- package/lib/index._auto-generated_.js +1 -0
- package/lib/index._auto-generated_.js.map +1 -1
- package/lib/local-translation.d.ts +67 -0
- package/lib/local-translation.js +172 -0
- package/lib/local-translation.js.map +1 -0
- package/lib/package.json +1 -1
- package/lib/start-cli.d.ts +0 -5
- package/lib/start-cli.js +9 -39
- package/lib/start-cli.js.map +1 -1
- package/lib/utils-po-file-extracto-to-json.test.d.ts +1 -0
- package/lib/utils-po-file-extracto-to-json.test.js +147 -0
- package/lib/utils-po-file-extracto-to-json.test.js.map +1 -0
- package/lib/utils-po-file.js +26 -13
- package/lib/utils-po-file.js.map +1 -1
- package/lib/utils-po-file.test.js +2 -0
- package/lib/utils-po-file.test.js.map +1 -1
- package/lib-esm/app/main-page/main-page.active.context.d.ts +5 -5
- package/lib-esm/app/main-page/main-page.active.context.js +1 -1
- package/lib-esm/app/main-page/main-page.active.context.js.map +1 -1
- package/lib-esm/app.cloudflare.d.ts +0 -0
- package/lib-esm/app.cloudflare.js +4 -0
- package/lib-esm/app.cloudflare.js.map +1 -0
- package/lib-esm/app.d.ts +1 -1
- package/lib-esm/app.electron.d.ts +1 -1
- package/lib-esm/app.electron.js +1 -1
- package/lib-esm/app.hosts.d.ts +3 -3
- package/lib-esm/app.hosts.js +8 -8
- package/lib-esm/app.js +1 -1
- package/lib-esm/app.js.map +1 -1
- package/lib-esm/app.vscode.d.ts +0 -9
- package/lib-esm/app.vscode.js +54 -36
- package/lib-esm/app.vscode.js.map +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/i18n/lib.translation.d.ts +1 -1
- package/lib-esm/lib/index._auto-generated_.d.ts +1 -0
- package/lib-esm/lib/index._auto-generated_.js +1 -0
- package/lib-esm/lib/index._auto-generated_.js.map +1 -1
- package/lib-esm/lib/local-translation.d.ts +67 -0
- package/lib-esm/lib/local-translation.js +168 -0
- package/lib-esm/lib/local-translation.js.map +1 -0
- package/lib-esm/lib/start-cli.d.ts +0 -5
- package/lib-esm/lib/start-cli.js +9 -39
- package/lib-esm/lib/start-cli.js.map +1 -1
- package/lib-esm/lib/translation-manager.d.ts +1 -1
- package/lib-esm/lib/translation-manager.js +1 -1
- package/lib-esm/lib/translation-manager.js.map +1 -1
- package/lib-esm/lib/translation.d.ts +1 -1
- package/lib-esm/lib/translation.js +1 -1
- package/lib-esm/lib/translation.js.map +1 -1
- package/lib-esm/lib/translation.models.d.ts +1 -1
- package/lib-esm/lib/utils-i18n-extract-gettext-translate-from-html.d.ts +1 -1
- package/lib-esm/lib/utils-i18n-html.d.ts +1 -1
- package/lib-esm/lib/utils-po-file-extracto-to-json.test.d.ts +1 -0
- package/lib-esm/lib/utils-po-file-extracto-to-json.test.js +145 -0
- package/lib-esm/lib/utils-po-file-extracto-to-json.test.js.map +1 -0
- package/lib-esm/lib/utils-po-file.d.ts +1 -1
- package/lib-esm/lib/utils-po-file.js +26 -13
- package/lib-esm/lib/utils-po-file.js.map +1 -1
- package/lib-esm/lib/utils-po-file.test.js +2 -0
- package/lib-esm/lib/utils-po-file.test.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 +1 -0
- package/lib-prod/index._auto-generated_.js +1 -0
- package/lib-prod/index._auto-generated_.js.map +1 -1
- package/lib-prod/local-translation.d.ts +67 -0
- package/lib-prod/local-translation.js +168 -0
- package/lib-prod/local-translation.js.map +1 -0
- package/lib-prod/package.json +1 -1
- package/lib-prod/start-cli.d.ts +0 -5
- package/lib-prod/start-cli.js +9 -39
- package/lib-prod/start-cli.js.map +1 -1
- package/lib-prod/utils-po-file-extracto-to-json.test.d.ts +1 -0
- package/lib-prod/utils-po-file-extracto-to-json.test.js +145 -0
- package/lib-prod/utils-po-file-extracto-to-json.test.js.map +1 -0
- package/lib-prod/utils-po-file.js +26 -13
- package/lib-prod/utils-po-file.js.map +1 -1
- package/lib-prod/utils-po-file.test.js +2 -0
- package/lib-prod/utils-po-file.test.js.map +1 -1
- package/package.json +1 -1
- package/websql/fesm2022/i18n-websql.mjs +220 -35
- package/websql/fesm2022/i18n-websql.mjs.map +1 -1
- package/websql/package.json +1 -1
- package/websql/types/i18n-websql.d.ts +73 -11
- package/websql-prod/fesm2022/i18n-websql-prod.mjs +220 -35
- 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 +73 -11
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { mkdirSync } from 'node:fs';
|
|
2
|
+
import { crossPlatformPath, dotTaonFolder, UtilsOs__NS__getRealHomeDir, GlobalStorage, ___NS__isNil, UtilsI18n__NS__detectLocale, UtilsI18n__NS__defaultLangLocale, ___NS__cloneDeep, UtilsI18n__NS__LangOptionArr, ___NS__isObject } from 'tnp-core/browser-prod';
|
|
1
3
|
import * as i0 from '@angular/core';
|
|
2
4
|
import { inject, ChangeDetectorRef, signal, ElementRef, DestroyRef, Input, Directive, Pipe, Injectable } from '@angular/core';
|
|
3
5
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
4
6
|
import { BehaviorSubject, tap, map } from 'rxjs';
|
|
5
|
-
import { GlobalStorage, ___NS__isNil, UtilsI18n__NS__detectLocale, UtilsI18n__NS__defaultLangLocale, ___NS__cloneDeep, UtilsI18n__NS__LangOptionArr, ___NS__isObject } from 'tnp-core/browser-prod';
|
|
6
7
|
|
|
7
8
|
// THIS FILE IS GENERATED - DO NOT MODIFY
|
|
8
9
|
/**
|
|
@@ -28,42 +29,202 @@ const CURRENT_PACKAGE_TAON_VERSION = 'v21';
|
|
|
28
29
|
/**
|
|
29
30
|
* Autogenerated by current cli tool. Use *tnp release* to bump version.
|
|
30
31
|
*/
|
|
31
|
-
const CURRENT_PACKAGE_VERSION = '21.0.
|
|
32
|
+
const CURRENT_PACKAGE_VERSION = '21.0.33';
|
|
32
33
|
// THIS FILE IS GENERATED - DO NOT MODIFY
|
|
33
34
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
35
|
+
const MODEL_ID = 'Xenova/nllb-200-distilled-600M';
|
|
36
|
+
const nllbLanguageCodes = {
|
|
37
|
+
'en-US': 'eng_Latn',
|
|
38
|
+
'pl-PL': 'pol_Latn',
|
|
39
|
+
'de-DE': 'deu_Latn',
|
|
40
|
+
};
|
|
41
|
+
class LocalTranslationService {
|
|
42
|
+
constructor() {
|
|
43
|
+
this.aiReady = false;
|
|
44
|
+
this.progressListeners = new Set();
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Downloads, caches and loads the translation model.
|
|
48
|
+
*
|
|
49
|
+
* Multiple simultaneous calls share the same initialization promise.
|
|
50
|
+
* After this resolves, translate() reuses the already loaded model.
|
|
51
|
+
*/
|
|
52
|
+
async makeSureAiDownloaded(options = {}) {
|
|
53
|
+
/* */
|
|
54
|
+
/* */
|
|
55
|
+
/* */
|
|
56
|
+
/* */
|
|
57
|
+
/* */
|
|
58
|
+
/* */
|
|
59
|
+
/* */
|
|
60
|
+
/* */
|
|
61
|
+
/* */
|
|
62
|
+
/* */
|
|
63
|
+
/* */
|
|
64
|
+
/* */
|
|
65
|
+
/* */
|
|
66
|
+
/* */
|
|
67
|
+
/* */
|
|
68
|
+
/* */
|
|
69
|
+
/* */
|
|
70
|
+
/* */
|
|
71
|
+
return (void 0);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* True only in this process after pipeline initialization succeeded.
|
|
75
|
+
*/
|
|
76
|
+
isAiReady() {
|
|
77
|
+
return this.aiReady;
|
|
78
|
+
}
|
|
79
|
+
getTranslator() {
|
|
80
|
+
this.translatorPromise ??= this.createTranslator().catch(error => {
|
|
81
|
+
// Allow a later call to retry after a network or disk failure.
|
|
82
|
+
this.translatorPromise = undefined;
|
|
83
|
+
this.aiReady = false;
|
|
84
|
+
throw error;
|
|
85
|
+
});
|
|
86
|
+
return this.translatorPromise;
|
|
87
|
+
}
|
|
88
|
+
async createTranslator() {
|
|
89
|
+
/* */
|
|
90
|
+
/* */
|
|
91
|
+
/* */
|
|
92
|
+
/* */
|
|
93
|
+
/* */
|
|
94
|
+
/* */
|
|
95
|
+
/* */
|
|
96
|
+
/* */
|
|
97
|
+
/* */
|
|
98
|
+
/* */
|
|
99
|
+
/* */
|
|
100
|
+
/* */
|
|
101
|
+
/* */
|
|
102
|
+
/* */
|
|
103
|
+
/* */
|
|
104
|
+
/* */
|
|
105
|
+
/* */
|
|
106
|
+
/* */
|
|
107
|
+
/* */
|
|
108
|
+
/* */
|
|
109
|
+
/* */
|
|
110
|
+
/* */
|
|
111
|
+
/* */
|
|
112
|
+
return (void 0);
|
|
113
|
+
}
|
|
114
|
+
emitProgress(progress) {
|
|
115
|
+
for (const listener of this.progressListeners) {
|
|
116
|
+
try {
|
|
117
|
+
listener(progress);
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
// A UI callback must not break model initialization.
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
warmupTranslator(translator) {
|
|
125
|
+
this.warmupPromise ??= translator('Hello.', {
|
|
126
|
+
src_lang: 'eng_Latn',
|
|
127
|
+
tgt_lang: 'pol_Latn',
|
|
128
|
+
max_new_tokens: 16,
|
|
129
|
+
})
|
|
130
|
+
.then(() => undefined)
|
|
131
|
+
.catch(error => {
|
|
132
|
+
this.warmupPromise = undefined;
|
|
133
|
+
throw error;
|
|
134
|
+
});
|
|
135
|
+
return this.warmupPromise;
|
|
136
|
+
}
|
|
137
|
+
async translate(options) {
|
|
138
|
+
/* */
|
|
139
|
+
/* */
|
|
140
|
+
/* */
|
|
141
|
+
/* */
|
|
142
|
+
/* */
|
|
143
|
+
/* */
|
|
144
|
+
/* */
|
|
145
|
+
/* */
|
|
146
|
+
/* */
|
|
147
|
+
/* */
|
|
148
|
+
/* */
|
|
149
|
+
/* */
|
|
150
|
+
/* */
|
|
151
|
+
/* */
|
|
152
|
+
/* */
|
|
153
|
+
/* */
|
|
154
|
+
/* */
|
|
155
|
+
/* */
|
|
156
|
+
/* */
|
|
157
|
+
/* */
|
|
158
|
+
/* */
|
|
159
|
+
/* */
|
|
160
|
+
/* */
|
|
161
|
+
/* */
|
|
162
|
+
/* */
|
|
163
|
+
/* */
|
|
164
|
+
/* */
|
|
165
|
+
/* */
|
|
166
|
+
/* */
|
|
167
|
+
/* */
|
|
168
|
+
/* */
|
|
169
|
+
/* */
|
|
170
|
+
/* */
|
|
171
|
+
/* */
|
|
172
|
+
/* */
|
|
173
|
+
/* */
|
|
174
|
+
/* */
|
|
175
|
+
/* */
|
|
176
|
+
/* */
|
|
177
|
+
/* */
|
|
178
|
+
/* */
|
|
179
|
+
/* */
|
|
180
|
+
/* */
|
|
181
|
+
/* */
|
|
182
|
+
return (void 0);
|
|
183
|
+
}
|
|
184
|
+
protectGlossary(text, glossary) {
|
|
185
|
+
if (!glossary || Object.keys(glossary).length === 0) {
|
|
186
|
+
return {
|
|
187
|
+
preparedText: text,
|
|
188
|
+
restore: translatedText => translatedText,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
const replacements = [];
|
|
192
|
+
let preparedText = text;
|
|
193
|
+
Object.entries(glossary)
|
|
194
|
+
.sort(([left], [right]) => right.length - left.length)
|
|
195
|
+
.forEach(([sourceValue, translatedValue], index) => {
|
|
196
|
+
const placeholder = `TAONTERM${index}PLACEHOLDER`;
|
|
197
|
+
preparedText = preparedText.replaceAll(sourceValue, placeholder);
|
|
198
|
+
replacements.push({
|
|
199
|
+
placeholder,
|
|
200
|
+
translatedValue,
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
return {
|
|
204
|
+
preparedText,
|
|
205
|
+
restore(translatedText) {
|
|
206
|
+
let result = translatedText;
|
|
207
|
+
for (const replacement of replacements) {
|
|
208
|
+
result = result.replaceAll(replacement.placeholder, replacement.translatedValue);
|
|
209
|
+
}
|
|
210
|
+
return result;
|
|
211
|
+
},
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
getModelsCachePath() {
|
|
215
|
+
const cachePath = crossPlatformPath([
|
|
216
|
+
UtilsOs__NS__getRealHomeDir(),
|
|
217
|
+
dotTaonFolder,
|
|
218
|
+
'ai-models-cache',
|
|
219
|
+
]);
|
|
220
|
+
mkdirSync(cachePath, {
|
|
221
|
+
recursive: true,
|
|
222
|
+
});
|
|
223
|
+
return cachePath;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
51
227
|
async function startCli(argsv, filename) {
|
|
52
|
-
/* */
|
|
53
|
-
/* */
|
|
54
|
-
/* */
|
|
55
|
-
/* */
|
|
56
|
-
/* */
|
|
57
|
-
/* */
|
|
58
|
-
/* */
|
|
59
|
-
/* */
|
|
60
|
-
/* */
|
|
61
|
-
/* */
|
|
62
|
-
/* */
|
|
63
|
-
/* */
|
|
64
|
-
/* */
|
|
65
|
-
/* */
|
|
66
|
-
/* */
|
|
67
228
|
/* */
|
|
68
229
|
/* */
|
|
69
230
|
/* */
|
|
@@ -1504,6 +1665,8 @@ function UtilsPoFile__NS__generatePoFileContent(files, locale) {
|
|
|
1504
1665
|
/* */
|
|
1505
1666
|
/* */
|
|
1506
1667
|
/* */
|
|
1668
|
+
/* */
|
|
1669
|
+
/* */
|
|
1507
1670
|
return (void 0);
|
|
1508
1671
|
}
|
|
1509
1672
|
//#endregion
|
|
@@ -1540,6 +1703,15 @@ function UtilsPoFile__NS__extractPoToJson(poFileContent) {
|
|
|
1540
1703
|
/* */
|
|
1541
1704
|
/* */
|
|
1542
1705
|
/* */
|
|
1706
|
+
/* */
|
|
1707
|
+
/* */
|
|
1708
|
+
/* */
|
|
1709
|
+
/* */
|
|
1710
|
+
/* */
|
|
1711
|
+
/* */
|
|
1712
|
+
/* */
|
|
1713
|
+
/* */
|
|
1714
|
+
/* */
|
|
1543
1715
|
return (void 0);
|
|
1544
1716
|
}
|
|
1545
1717
|
//#endregion
|
|
@@ -1684,6 +1856,10 @@ function parsePoEntries(po) {
|
|
|
1684
1856
|
/* */
|
|
1685
1857
|
/* */
|
|
1686
1858
|
/* */
|
|
1859
|
+
/* */
|
|
1860
|
+
/* */
|
|
1861
|
+
/* */
|
|
1862
|
+
/* */
|
|
1687
1863
|
return (void 0);
|
|
1688
1864
|
}
|
|
1689
1865
|
function parsePoRef(ref) {
|
|
@@ -1695,6 +1871,9 @@ function parsePoRef(ref) {
|
|
|
1695
1871
|
/* */
|
|
1696
1872
|
/* */
|
|
1697
1873
|
/* */
|
|
1874
|
+
/* */
|
|
1875
|
+
/* */
|
|
1876
|
+
/* */
|
|
1698
1877
|
return (void 0);
|
|
1699
1878
|
}
|
|
1700
1879
|
function escapePoString(value) {
|
|
@@ -1709,6 +1888,12 @@ function readPoQuoted(value) {
|
|
|
1709
1888
|
return '';
|
|
1710
1889
|
return unescapePoString(match[1]);
|
|
1711
1890
|
}
|
|
1891
|
+
function normalizePoTranslation(translation) {
|
|
1892
|
+
if (translation === undefined || translation === null) {
|
|
1893
|
+
return undefined;
|
|
1894
|
+
}
|
|
1895
|
+
return translation.trim().length > 0 ? translation : undefined;
|
|
1896
|
+
}
|
|
1712
1897
|
function unescapePoString(value) {
|
|
1713
1898
|
return value
|
|
1714
1899
|
.replace(/\\n/g, '\n')
|
|
@@ -1733,5 +1918,5 @@ var index = {};
|
|
|
1733
1918
|
* Generated bundle index. Do not edit.
|
|
1734
1919
|
*/
|
|
1735
1920
|
|
|
1736
|
-
export { APP_ID, BUILD_BASE_HREF, BUILD_FRAMEWORK_CLI_NAME, CURRENT_PACKAGE_TAON_VERSION, CURRENT_PACKAGE_VERSION, PROJECT_NPM_NAME, TranslateDirective, TranslatePipe, TranslateService, Translation, TranslationManager, UtilsI18nExtractGettextTranslateFromHtml__NS__extractGettextTranslateFromHtml, UtilsI18nHtml__NS__extractGettextTranslateFromHtml, UtilsI18nHtml__NS__isAngularTsWithInlineHtml, UtilsI18nHtml__NS__replaceTranslatePipieDirectiveTContext, UtilsI18nHtml__NS__replaceTranslatePipieDirectiveTContextInHtml, UtilsPoFile__NS__extractPoToJson, UtilsPoFile__NS__generatePoFileContent, UtilsPoFile__NS__generatePoFiles, UtilsPoFile__NS__generateTranslationOverrideInterface, UtilsPoFile__NS__mergeGettextFile, startCli };
|
|
1921
|
+
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__NS__extractGettextTranslateFromHtml, UtilsI18nHtml__NS__extractGettextTranslateFromHtml, UtilsI18nHtml__NS__isAngularTsWithInlineHtml, UtilsI18nHtml__NS__replaceTranslatePipieDirectiveTContext, UtilsI18nHtml__NS__replaceTranslatePipieDirectiveTContextInHtml, UtilsPoFile__NS__extractPoToJson, UtilsPoFile__NS__generatePoFileContent, UtilsPoFile__NS__generatePoFiles, UtilsPoFile__NS__generateTranslationOverrideInterface, UtilsPoFile__NS__mergeGettextFile, startCli };
|
|
1737
1922
|
//# sourceMappingURL=i18n-browser-prod.mjs.map
|