@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.
Files changed (103) hide show
  1. package/VERIFIED-BUILD-DATA.jsonc +2 -2
  2. package/bin/start.js +1 -1
  3. package/browser/fesm2022/i18n-browser.mjs +220 -35
  4. package/browser/fesm2022/i18n-browser.mjs.map +1 -1
  5. package/browser/package.json +1 -1
  6. package/browser/types/i18n-browser.d.ts +73 -11
  7. package/browser-prod/fesm2022/i18n-browser-prod.mjs +220 -35
  8. package/browser-prod/fesm2022/i18n-browser-prod.mjs.map +1 -1
  9. package/browser-prod/package.json +1 -1
  10. package/browser-prod/types/i18n-browser-prod.d.ts +73 -11
  11. package/html/assets/generated/pwa/html-pwa.html +53 -53
  12. package/lib/build-info._auto-generated_.d.ts +1 -1
  13. package/lib/build-info._auto-generated_.js +1 -1
  14. package/lib/index._auto-generated_.d.ts +1 -0
  15. package/lib/index._auto-generated_.js +1 -0
  16. package/lib/index._auto-generated_.js.map +1 -1
  17. package/lib/local-translation.d.ts +67 -0
  18. package/lib/local-translation.js +172 -0
  19. package/lib/local-translation.js.map +1 -0
  20. package/lib/package.json +1 -1
  21. package/lib/start-cli.d.ts +0 -5
  22. package/lib/start-cli.js +9 -39
  23. package/lib/start-cli.js.map +1 -1
  24. package/lib/utils-po-file-extracto-to-json.test.d.ts +1 -0
  25. package/lib/utils-po-file-extracto-to-json.test.js +147 -0
  26. package/lib/utils-po-file-extracto-to-json.test.js.map +1 -0
  27. package/lib/utils-po-file.js +26 -13
  28. package/lib/utils-po-file.js.map +1 -1
  29. package/lib/utils-po-file.test.js +2 -0
  30. package/lib/utils-po-file.test.js.map +1 -1
  31. package/lib-esm/app/main-page/main-page.active.context.d.ts +5 -5
  32. package/lib-esm/app/main-page/main-page.active.context.js +1 -1
  33. package/lib-esm/app/main-page/main-page.active.context.js.map +1 -1
  34. package/lib-esm/app.cloudflare.d.ts +0 -0
  35. package/lib-esm/app.cloudflare.js +4 -0
  36. package/lib-esm/app.cloudflare.js.map +1 -0
  37. package/lib-esm/app.d.ts +1 -1
  38. package/lib-esm/app.electron.d.ts +1 -1
  39. package/lib-esm/app.electron.js +1 -1
  40. package/lib-esm/app.hosts.d.ts +3 -3
  41. package/lib-esm/app.hosts.js +8 -8
  42. package/lib-esm/app.js +1 -1
  43. package/lib-esm/app.js.map +1 -1
  44. package/lib-esm/app.vscode.d.ts +0 -9
  45. package/lib-esm/app.vscode.js +54 -36
  46. package/lib-esm/app.vscode.js.map +1 -1
  47. package/lib-esm/lib/build-info._auto-generated_.d.ts +1 -1
  48. package/lib-esm/lib/build-info._auto-generated_.js +1 -1
  49. package/lib-esm/lib/i18n/lib.translation.d.ts +1 -1
  50. package/lib-esm/lib/index._auto-generated_.d.ts +1 -0
  51. package/lib-esm/lib/index._auto-generated_.js +1 -0
  52. package/lib-esm/lib/index._auto-generated_.js.map +1 -1
  53. package/lib-esm/lib/local-translation.d.ts +67 -0
  54. package/lib-esm/lib/local-translation.js +168 -0
  55. package/lib-esm/lib/local-translation.js.map +1 -0
  56. package/lib-esm/lib/start-cli.d.ts +0 -5
  57. package/lib-esm/lib/start-cli.js +9 -39
  58. package/lib-esm/lib/start-cli.js.map +1 -1
  59. package/lib-esm/lib/translation-manager.d.ts +1 -1
  60. package/lib-esm/lib/translation-manager.js +1 -1
  61. package/lib-esm/lib/translation-manager.js.map +1 -1
  62. package/lib-esm/lib/translation.d.ts +1 -1
  63. package/lib-esm/lib/translation.js +1 -1
  64. package/lib-esm/lib/translation.js.map +1 -1
  65. package/lib-esm/lib/translation.models.d.ts +1 -1
  66. package/lib-esm/lib/utils-i18n-extract-gettext-translate-from-html.d.ts +1 -1
  67. package/lib-esm/lib/utils-i18n-html.d.ts +1 -1
  68. package/lib-esm/lib/utils-po-file-extracto-to-json.test.d.ts +1 -0
  69. package/lib-esm/lib/utils-po-file-extracto-to-json.test.js +145 -0
  70. package/lib-esm/lib/utils-po-file-extracto-to-json.test.js.map +1 -0
  71. package/lib-esm/lib/utils-po-file.d.ts +1 -1
  72. package/lib-esm/lib/utils-po-file.js +26 -13
  73. package/lib-esm/lib/utils-po-file.js.map +1 -1
  74. package/lib-esm/lib/utils-po-file.test.js +2 -0
  75. package/lib-esm/lib/utils-po-file.test.js.map +1 -1
  76. package/lib-prod/build-info._auto-generated_.d.ts +1 -1
  77. package/lib-prod/build-info._auto-generated_.js +1 -1
  78. package/lib-prod/index._auto-generated_.d.ts +1 -0
  79. package/lib-prod/index._auto-generated_.js +1 -0
  80. package/lib-prod/index._auto-generated_.js.map +1 -1
  81. package/lib-prod/local-translation.d.ts +67 -0
  82. package/lib-prod/local-translation.js +168 -0
  83. package/lib-prod/local-translation.js.map +1 -0
  84. package/lib-prod/package.json +1 -1
  85. package/lib-prod/start-cli.d.ts +0 -5
  86. package/lib-prod/start-cli.js +9 -39
  87. package/lib-prod/start-cli.js.map +1 -1
  88. package/lib-prod/utils-po-file-extracto-to-json.test.d.ts +1 -0
  89. package/lib-prod/utils-po-file-extracto-to-json.test.js +145 -0
  90. package/lib-prod/utils-po-file-extracto-to-json.test.js.map +1 -0
  91. package/lib-prod/utils-po-file.js +26 -13
  92. package/lib-prod/utils-po-file.js.map +1 -1
  93. package/lib-prod/utils-po-file.test.js +2 -0
  94. package/lib-prod/utils-po-file.test.js.map +1 -1
  95. package/package.json +1 -1
  96. package/websql/fesm2022/i18n-websql.mjs +220 -35
  97. package/websql/fesm2022/i18n-websql.mjs.map +1 -1
  98. package/websql/package.json +1 -1
  99. package/websql/types/i18n-websql.d.ts +73 -11
  100. package/websql-prod/fesm2022/i18n-websql-prod.mjs +220 -35
  101. package/websql-prod/fesm2022/i18n-websql-prod.mjs.map +1 -1
  102. package/websql-prod/package.json +1 -1
  103. package/websql-prod/types/i18n-websql-prod.d.ts +73 -11
@@ -1,5 +1,5 @@
1
1
  {
2
- "commitHash": "072b8933ba37fb496d44cd563941a85541399e86",
2
+ "commitHash": "4a3660b92dfe2474b5d9fedc114f982f2d10c94e",
3
3
  "commitName": "chore: update",
4
- "commitDate": "19-07-2026 13:38:22"
4
+ "commitDate": "30-07-2026 09:40:16"
5
5
  }
package/bin/start.js CHANGED
@@ -1,4 +1,4 @@
1
- global.frameworkName = 'i18n';
1
+ global.frameworkName = 'i18n';
2
2
  Error.stackTraceLimit = 100;
3
3
  global.i0 = {
4
4
  defineInjectable: function () { }
@@ -1,8 +1,9 @@
1
+ import { mkdirSync } from 'node:fs';
2
+ import { crossPlatformPath, dotTaonFolder, UtilsOs, GlobalStorage, _, UtilsI18n } from 'tnp-core/browser';
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/browser';
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.27';
32
+ const CURRENT_PACKAGE_VERSION = '21.0.33';
32
33
  // THIS FILE IS GENERATED - DO NOT MODIFY
33
34
 
34
- //#region tnp-helpers cli template
35
- // import { CoreModels } from 'tnp-core/src';
36
- // import { Helpers, BaseCommandLineFeature } from 'tnp-helpers/src';
37
- // import { BaseProject, BaseStartConfig } from 'tnp-helpers/src'; // @backend
38
- // class $Global extends BaseCommandLineFeature<{}> {
39
- // static [CoreModels.ClassNameStaticProperty] = '';
40
- // public _() {
41
- // console.log(`Hello world from cli`);
42
- // this._exit();
43
- // }
44
- // }
45
- //#endregion
46
- /**
47
- *
48
- * @param argsv process.argsv
49
- * @param filename needed if you want ipc communicaiton
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-browser.mjs.map