@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, GlobalStorage, _, UtilsI18n } from 'tnp-core/websql';
|
|
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, _, UtilsI18n } from 'tnp-core/websql';
|
|
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.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
|
/* */
|
|
@@ -1513,6 +1674,8 @@ var UtilsPoFile;
|
|
|
1513
1674
|
/* */
|
|
1514
1675
|
/* */
|
|
1515
1676
|
/* */
|
|
1677
|
+
/* */
|
|
1678
|
+
/* */
|
|
1516
1679
|
return (void 0);
|
|
1517
1680
|
}
|
|
1518
1681
|
UtilsPoFile.generatePoFileContent = generatePoFileContent;
|
|
@@ -1550,6 +1713,15 @@ var UtilsPoFile;
|
|
|
1550
1713
|
/* */
|
|
1551
1714
|
/* */
|
|
1552
1715
|
/* */
|
|
1716
|
+
/* */
|
|
1717
|
+
/* */
|
|
1718
|
+
/* */
|
|
1719
|
+
/* */
|
|
1720
|
+
/* */
|
|
1721
|
+
/* */
|
|
1722
|
+
/* */
|
|
1723
|
+
/* */
|
|
1724
|
+
/* */
|
|
1553
1725
|
return (void 0);
|
|
1554
1726
|
}
|
|
1555
1727
|
UtilsPoFile.extractPoToJson = extractPoToJson;
|
|
@@ -1697,6 +1869,10 @@ var UtilsPoFile;
|
|
|
1697
1869
|
/* */
|
|
1698
1870
|
/* */
|
|
1699
1871
|
/* */
|
|
1872
|
+
/* */
|
|
1873
|
+
/* */
|
|
1874
|
+
/* */
|
|
1875
|
+
/* */
|
|
1700
1876
|
return (void 0);
|
|
1701
1877
|
}
|
|
1702
1878
|
function parsePoRef(ref) {
|
|
@@ -1708,6 +1884,9 @@ var UtilsPoFile;
|
|
|
1708
1884
|
/* */
|
|
1709
1885
|
/* */
|
|
1710
1886
|
/* */
|
|
1887
|
+
/* */
|
|
1888
|
+
/* */
|
|
1889
|
+
/* */
|
|
1711
1890
|
return (void 0);
|
|
1712
1891
|
}
|
|
1713
1892
|
function escapePoString(value) {
|
|
@@ -1722,6 +1901,12 @@ var UtilsPoFile;
|
|
|
1722
1901
|
return '';
|
|
1723
1902
|
return unescapePoString(match[1]);
|
|
1724
1903
|
}
|
|
1904
|
+
function normalizePoTranslation(translation) {
|
|
1905
|
+
if (translation === undefined || translation === null) {
|
|
1906
|
+
return undefined;
|
|
1907
|
+
}
|
|
1908
|
+
return translation.trim().length > 0 ? translation : undefined;
|
|
1909
|
+
}
|
|
1725
1910
|
function unescapePoString(value) {
|
|
1726
1911
|
return value
|
|
1727
1912
|
.replace(/\\n/g, '\n')
|
|
@@ -1746,5 +1931,5 @@ var index = {};
|
|
|
1746
1931
|
* Generated bundle index. Do not edit.
|
|
1747
1932
|
*/
|
|
1748
1933
|
|
|
1749
|
-
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, UtilsI18nHtml, UtilsPoFile, startCli };
|
|
1934
|
+
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 };
|
|
1750
1935
|
//# sourceMappingURL=i18n-websql.mjs.map
|