@theia/localization-manager 1.53.0-next.5 → 1.53.0-next.55
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/README.md +67 -67
- package/lib/deepl-api.d.ts +2 -1
- package/lib/deepl-api.d.ts.map +1 -1
- package/lib/deepl-api.js +11 -4
- package/lib/deepl-api.js.map +1 -1
- package/lib/localization-extractor.spec.js +26 -26
- package/lib/localization-manager.d.ts +2 -2
- package/lib/localization-manager.d.ts.map +1 -1
- package/lib/localization-manager.js +11 -3
- package/lib/localization-manager.js.map +1 -1
- package/package.json +3 -3
- package/src/common.ts +27 -27
- package/src/deepl-api.ts +168 -153
- package/src/index.ts +19 -19
- package/src/localization-extractor.spec.ts +151 -151
- package/src/localization-extractor.ts +431 -431
- package/src/localization-manager.spec.ts +91 -91
- package/src/localization-manager.ts +168 -160
package/README.md
CHANGED
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
<div align='center'>
|
|
2
|
-
|
|
3
|
-
<br />
|
|
4
|
-
|
|
5
|
-
<img src='https://raw.githubusercontent.com/eclipse-theia/theia/master/logo/theia.svg?sanitize=true' alt='theia-ext-logo' width='100px' />
|
|
6
|
-
|
|
7
|
-
<h2>ECLIPSE THEIA - LOCALIZATION-MANAGER</h2>
|
|
8
|
-
|
|
9
|
-
<hr />
|
|
10
|
-
|
|
11
|
-
</div>
|
|
12
|
-
|
|
13
|
-
## Description
|
|
14
|
-
|
|
15
|
-
The `@theia/localization-manager` package is used easily create localizations of Theia and Theia extensions for different languages. It has two main use cases.
|
|
16
|
-
|
|
17
|
-
First, it allows to extract localization keys and default values from `nls.localize` calls within the codebase using the `nls-extract` Theia-CLI command. Take this code for example:
|
|
18
|
-
|
|
19
|
-
```ts
|
|
20
|
-
const hi = nls.localize('greetings/hi', 'Hello');
|
|
21
|
-
const bye = nls.localize('greetings/bye', 'Bye');
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
It will be converted into this JSON file (`nls.json`):
|
|
25
|
-
|
|
26
|
-
```json
|
|
27
|
-
{
|
|
28
|
-
"greetings": {
|
|
29
|
-
"hi": "Hello",
|
|
30
|
-
"bye": "Bye"
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
Afterwards, any manual or automatic translation approach can be used to translate this file into other languages. These JSON files are supposed to be picked up by `LocalizationContribution`s.
|
|
36
|
-
|
|
37
|
-
Additionally, Theia provides a simple way to translate the generated JSON files out of the box using the [DeepL API](https://www.deepl.com/docs-api). For this, a [DeepL free or pro account](https://www.deepl.com/pro) is needed. Using the `nls-localize` command of the Theia-CLI, a target file can be translated into different languages. For example, when calling the command using the previous JSON file with the `fr` (french) language, the following `nls.fr.json` file will be created in the same directory as the translation source:
|
|
38
|
-
|
|
39
|
-
```json
|
|
40
|
-
{
|
|
41
|
-
"greetings": {
|
|
42
|
-
"hi": "Bonjour",
|
|
43
|
-
"bye": "Au revoir"
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
Only JSON entries without corresponding translations are translated using DeepL. This ensures that manual changes to the translated files aren't overwritten and only new translation entries are actually sent to DeepL.
|
|
50
|
-
|
|
51
|
-
Use `theia nls-localize --help` for more information on how to use the command and supply DeepL API keys.
|
|
52
|
-
|
|
53
|
-
For more information, see the [internationalization documentation](https://theia-ide.org/docs/i18n/).
|
|
54
|
-
|
|
55
|
-
## Additional Information
|
|
56
|
-
|
|
57
|
-
- [Theia - GitHub](https://github.com/eclipse-theia/theia)
|
|
58
|
-
- [Theia - Website](https://theia-ide.org/)
|
|
59
|
-
|
|
60
|
-
## License
|
|
61
|
-
|
|
62
|
-
- [Eclipse Public License 2.0](http://www.eclipse.org/legal/epl-2.0/)
|
|
63
|
-
- [一 (Secondary) GNU General Public License, version 2 with the GNU Classpath Exception](https://projects.eclipse.org/license/secondary-gpl-2.0-cp)
|
|
64
|
-
|
|
65
|
-
## Trademark
|
|
66
|
-
"Theia" is a trademark of the Eclipse Foundation
|
|
67
|
-
https://www.eclipse.org/theia
|
|
1
|
+
<div align='center'>
|
|
2
|
+
|
|
3
|
+
<br />
|
|
4
|
+
|
|
5
|
+
<img src='https://raw.githubusercontent.com/eclipse-theia/theia/master/logo/theia.svg?sanitize=true' alt='theia-ext-logo' width='100px' />
|
|
6
|
+
|
|
7
|
+
<h2>ECLIPSE THEIA - LOCALIZATION-MANAGER</h2>
|
|
8
|
+
|
|
9
|
+
<hr />
|
|
10
|
+
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
## Description
|
|
14
|
+
|
|
15
|
+
The `@theia/localization-manager` package is used easily create localizations of Theia and Theia extensions for different languages. It has two main use cases.
|
|
16
|
+
|
|
17
|
+
First, it allows to extract localization keys and default values from `nls.localize` calls within the codebase using the `nls-extract` Theia-CLI command. Take this code for example:
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
const hi = nls.localize('greetings/hi', 'Hello');
|
|
21
|
+
const bye = nls.localize('greetings/bye', 'Bye');
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
It will be converted into this JSON file (`nls.json`):
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"greetings": {
|
|
29
|
+
"hi": "Hello",
|
|
30
|
+
"bye": "Bye"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Afterwards, any manual or automatic translation approach can be used to translate this file into other languages. These JSON files are supposed to be picked up by `LocalizationContribution`s.
|
|
36
|
+
|
|
37
|
+
Additionally, Theia provides a simple way to translate the generated JSON files out of the box using the [DeepL API](https://www.deepl.com/docs-api). For this, a [DeepL free or pro account](https://www.deepl.com/pro) is needed. Using the `nls-localize` command of the Theia-CLI, a target file can be translated into different languages. For example, when calling the command using the previous JSON file with the `fr` (french) language, the following `nls.fr.json` file will be created in the same directory as the translation source:
|
|
38
|
+
|
|
39
|
+
```json
|
|
40
|
+
{
|
|
41
|
+
"greetings": {
|
|
42
|
+
"hi": "Bonjour",
|
|
43
|
+
"bye": "Au revoir"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
Only JSON entries without corresponding translations are translated using DeepL. This ensures that manual changes to the translated files aren't overwritten and only new translation entries are actually sent to DeepL.
|
|
50
|
+
|
|
51
|
+
Use `theia nls-localize --help` for more information on how to use the command and supply DeepL API keys.
|
|
52
|
+
|
|
53
|
+
For more information, see the [internationalization documentation](https://theia-ide.org/docs/i18n/).
|
|
54
|
+
|
|
55
|
+
## Additional Information
|
|
56
|
+
|
|
57
|
+
- [Theia - GitHub](https://github.com/eclipse-theia/theia)
|
|
58
|
+
- [Theia - Website](https://theia-ide.org/)
|
|
59
|
+
|
|
60
|
+
## License
|
|
61
|
+
|
|
62
|
+
- [Eclipse Public License 2.0](http://www.eclipse.org/legal/epl-2.0/)
|
|
63
|
+
- [一 (Secondary) GNU General Public License, version 2 with the GNU Classpath Exception](https://projects.eclipse.org/license/secondary-gpl-2.0-cp)
|
|
64
|
+
|
|
65
|
+
## Trademark
|
|
66
|
+
"Theia" is a trademark of the Eclipse Foundation
|
|
67
|
+
https://www.eclipse.org/theia
|
package/lib/deepl-api.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare function deepl(parameters: DeeplParameters): Promise<DeeplResponse>;
|
|
2
|
-
export type DeeplLanguage = 'BG' | 'CS' | 'DA' | 'DE' | 'EL' | 'EN-GB' | 'EN-US' | 'EN' | 'ES' | 'ET' | 'FI' | 'FR' | 'HU' | 'IT' | 'JA' | 'LT' | 'LV' | 'NL' | 'PL' | 'PT-PT' | 'PT-BR' | 'PT' | 'RO' | 'RU' | 'SK' | 'SL' | 'SV' | 'ZH-CN' | 'ZH';
|
|
2
|
+
export type DeeplLanguage = 'BG' | 'CS' | 'DA' | 'DE' | 'EL' | 'EN-GB' | 'EN-US' | 'EN' | 'ES' | 'ET' | 'FI' | 'FR' | 'HU' | 'ID' | 'IT' | 'JA' | 'KO' | 'LT' | 'LV' | 'NB' | 'NL' | 'PL' | 'PT-PT' | 'PT-BR' | 'PT' | 'RO' | 'RU' | 'SK' | 'SL' | 'SV' | 'TR' | 'UK' | 'ZH-CN' | 'ZH-TW' | 'ZH-HANS' | 'ZH-HANT' | 'ZH';
|
|
3
3
|
export declare const supportedLanguages: string[];
|
|
4
|
+
export declare const defaultLanguages: readonly ["ZH-CN", "ZH-TW", "FR", "DE", "IT", "ES", "JA", "KO", "RU", "PT-BR", "TR", "PL", "CS", "HU"];
|
|
4
5
|
export declare function isSupportedLanguage(language: string): language is DeeplLanguage;
|
|
5
6
|
export interface DeeplParameters {
|
|
6
7
|
free_api: Boolean;
|
package/lib/deepl-api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deepl-api.d.ts","sourceRoot":"","sources":["../src/deepl-api.ts"],"names":[],"mappings":"AAsBA,wBAAsB,KAAK,CACvB,UAAU,EAAE,eAAe,GAC5B,OAAO,CAAC,aAAa,CAAC,CAuBxB;
|
|
1
|
+
{"version":3,"file":"deepl-api.d.ts","sourceRoot":"","sources":["../src/deepl-api.ts"],"names":[],"mappings":"AAsBA,wBAAsB,KAAK,CACvB,UAAU,EAAE,eAAe,GAC5B,OAAO,CAAC,aAAa,CAAC,CAuBxB;AA4CD,MAAM,MAAM,aAAa,GACnB,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,OAAO,GACP,OAAO,GACP,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,OAAO,GACP,OAAO,GACP,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,OAAO,GACP,OAAO,GACP,SAAS,GACT,SAAS,GACT,IAAI,CAAC;AAEX,eAAO,MAAM,kBAAkB,UAG9B,CAAC;AAGF,eAAO,MAAM,gBAAgB,wGAEnB,CAAC;AAEX,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,IAAI,aAAa,CAE/E;AAED,MAAM,WAAW,eAAe;IAC5B,QAAQ,EAAE,OAAO,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,WAAW,CAAC,EAAE,aAAa,CAAA;IAC3B,WAAW,EAAE,aAAa,CAAA;IAC1B,eAAe,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,YAAY,CAAA;IAC1C,mBAAmB,CAAC,EAAE,GAAG,GAAG,GAAG,CAAA;IAC/B,SAAS,CAAC,EAAE,SAAS,GAAG,MAAM,GAAG,MAAM,CAAA;IACvC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;IACvB,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC7B,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;IACzB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;CACzB;AAED,MAAM,WAAW,aAAa;IAC1B,YAAY,EAAE,gBAAgB,EAAE,CAAA;CACnC;AAED,MAAM,WAAW,gBAAgB;IAC7B,wBAAwB,EAAE,MAAM,CAAA;IAChC,IAAI,EAAE,MAAM,CAAA;CACf"}
|
package/lib/deepl-api.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
16
|
// *****************************************************************************
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.isSupportedLanguage = exports.supportedLanguages = exports.deepl = void 0;
|
|
18
|
+
exports.isSupportedLanguage = exports.defaultLanguages = exports.supportedLanguages = exports.deepl = void 0;
|
|
19
19
|
const bent = require("bent");
|
|
20
20
|
const post = bent('POST', 'json', 200);
|
|
21
21
|
// 50 is the maximum amount of translations per request
|
|
@@ -52,7 +52,10 @@ exports.deepl = deepl;
|
|
|
52
52
|
*/
|
|
53
53
|
function coerceLanguage(parameters) {
|
|
54
54
|
if (parameters.target_lang === 'ZH-CN') {
|
|
55
|
-
parameters.target_lang = 'ZH';
|
|
55
|
+
parameters.target_lang = 'ZH-HANS';
|
|
56
|
+
}
|
|
57
|
+
else if (parameters.target_lang === 'ZH-TW') {
|
|
58
|
+
parameters.target_lang = 'ZH-HANT';
|
|
56
59
|
}
|
|
57
60
|
}
|
|
58
61
|
/**
|
|
@@ -84,8 +87,12 @@ function toFormData(parameters) {
|
|
|
84
87
|
return str.join('&');
|
|
85
88
|
}
|
|
86
89
|
exports.supportedLanguages = [
|
|
87
|
-
'BG', 'CS', 'DA', 'DE', 'EL', 'EN-GB', 'EN-US', 'EN', 'ES', 'ET', 'FI', 'FR', 'HU', 'IT',
|
|
88
|
-
'JA', 'LT', 'LV', 'NL', 'PL', 'PT-PT', 'PT-BR', 'PT', 'RO', 'RU', 'SK', 'SL', 'SV', 'ZH-CN'
|
|
90
|
+
'BG', 'CS', 'DA', 'DE', 'EL', 'EN-GB', 'EN-US', 'EN', 'ES', 'ET', 'FI', 'FR', 'HU', 'ID', 'IT',
|
|
91
|
+
'JA', 'KO', 'LT', 'LV', 'NL', 'PL', 'PT-PT', 'PT-BR', 'PT', 'RO', 'RU', 'SK', 'SL', 'SV', 'TR', 'UK', 'ZH-CN', 'ZH-TW'
|
|
92
|
+
];
|
|
93
|
+
// From https://code.visualstudio.com/docs/getstarted/locales#_available-locales
|
|
94
|
+
exports.defaultLanguages = [
|
|
95
|
+
'ZH-CN', 'ZH-TW', 'FR', 'DE', 'IT', 'ES', 'JA', 'KO', 'RU', 'PT-BR', 'TR', 'PL', 'CS', 'HU'
|
|
89
96
|
];
|
|
90
97
|
function isSupportedLanguage(language) {
|
|
91
98
|
return exports.supportedLanguages.includes(language.toUpperCase());
|
package/lib/deepl-api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deepl-api.js","sourceRoot":"","sources":["../src/deepl-api.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;AAEhF,6BAA6B;AAE7B,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;AACvC,uDAAuD;AACvD,MAAM,UAAU,GAAG,EAAE,CAAC;AAEf,KAAK,UAAU,KAAK,CACvB,UAA2B;IAE3B,cAAc,CAAC,UAAU,CAAC,CAAC;IAC3B,MAAM,UAAU,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC;IAC5D,MAAM,UAAU,GAAe,EAAE,CAAC;IAClC,MAAM,SAAS,GAAG,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IACvC,OAAO,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC1B,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC;IACrD,CAAC;IACD,MAAM,SAAS,GAAoB,MAAM,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;QACxE,MAAM,aAAa,GAAoB,EAAE,GAAG,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;QACtE,OAAO,IAAI,CAAC,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AC;AACzB,CAAC;AAyCY,QAAA,kBAAkB,GAAG;IAC9B,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;IAC9F,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO;CACzH,CAAC;AAEF,gFAAgF;AACnE,QAAA,gBAAgB,GAAG;IAC5B,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;CACrF,CAAC;AAEX,SAAgB,mBAAmB,CAAC,QAAgB;IAChD,OAAO,0BAAkB,CAAC,QAAQ,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;AAC/D,CAAC;AAFD,kDAEC"}
|
|
@@ -35,15 +35,15 @@ describe('correctly extracts from file content', () => {
|
|
|
35
35
|
});
|
|
36
36
|
});
|
|
37
37
|
it('should extract IDs from Command.toLocalizedCommand() call', async () => {
|
|
38
|
-
const content = `
|
|
39
|
-
Command.toLocalizedCommand({
|
|
40
|
-
id: 'command-id1',
|
|
41
|
-
label: 'command-label1'
|
|
42
|
-
});
|
|
43
|
-
Command.toLocalizedCommand({
|
|
44
|
-
id: 'command-id2',
|
|
45
|
-
label: 'command-label2'
|
|
46
|
-
}, 'command-key');
|
|
38
|
+
const content = `
|
|
39
|
+
Command.toLocalizedCommand({
|
|
40
|
+
id: 'command-id1',
|
|
41
|
+
label: 'command-label1'
|
|
42
|
+
});
|
|
43
|
+
Command.toLocalizedCommand({
|
|
44
|
+
id: 'command-id2',
|
|
45
|
+
label: 'command-label2'
|
|
46
|
+
}, 'command-key');
|
|
47
47
|
`;
|
|
48
48
|
assert.deepStrictEqual(await (0, localization_extractor_1.extractFromFile)(TEST_FILE, content), {
|
|
49
49
|
'command-id1': 'command-label1',
|
|
@@ -51,11 +51,11 @@ describe('correctly extracts from file content', () => {
|
|
|
51
51
|
});
|
|
52
52
|
});
|
|
53
53
|
it('should extract category from Command.toLocalizedCommand() call', async () => {
|
|
54
|
-
const content = `
|
|
55
|
-
Command.toLocalizedCommand({
|
|
56
|
-
id: 'id',
|
|
57
|
-
label: 'label',
|
|
58
|
-
category: 'category'
|
|
54
|
+
const content = `
|
|
55
|
+
Command.toLocalizedCommand({
|
|
56
|
+
id: 'id',
|
|
57
|
+
label: 'label',
|
|
58
|
+
category: 'category'
|
|
59
59
|
}, undefined, 'category-key');`;
|
|
60
60
|
assert.deepStrictEqual(await (0, localization_extractor_1.extractFromFile)(TEST_FILE, content), {
|
|
61
61
|
'id': 'label',
|
|
@@ -63,9 +63,9 @@ describe('correctly extracts from file content', () => {
|
|
|
63
63
|
});
|
|
64
64
|
});
|
|
65
65
|
it('should merge different nls.localize() calls', async () => {
|
|
66
|
-
const content = `
|
|
67
|
-
nls.localize('nested/key1', 'value1');
|
|
68
|
-
nls.localize('nested/key2', 'value2');
|
|
66
|
+
const content = `
|
|
67
|
+
nls.localize('nested/key1', 'value1');
|
|
68
|
+
nls.localize('nested/key2', 'value2');
|
|
69
69
|
`;
|
|
70
70
|
assert.deepStrictEqual(await (0, localization_extractor_1.extractFromFile)(TEST_FILE, content), {
|
|
71
71
|
'nested': {
|
|
@@ -75,9 +75,9 @@ describe('correctly extracts from file content', () => {
|
|
|
75
75
|
});
|
|
76
76
|
});
|
|
77
77
|
it('should be able to resolve local references', async () => {
|
|
78
|
-
const content = `
|
|
79
|
-
const a = 'key';
|
|
80
|
-
nls.localize(a, 'value');
|
|
78
|
+
const content = `
|
|
79
|
+
const a = 'key';
|
|
80
|
+
nls.localize(a, 'value');
|
|
81
81
|
`;
|
|
82
82
|
assert.deepStrictEqual(await (0, localization_extractor_1.extractFromFile)(TEST_FILE, content), {
|
|
83
83
|
'key': 'value'
|
|
@@ -100,9 +100,9 @@ describe('correctly extracts from file content', () => {
|
|
|
100
100
|
]);
|
|
101
101
|
});
|
|
102
102
|
it('should show error when trying to merge an object and a string', async () => {
|
|
103
|
-
const content = `
|
|
104
|
-
nls.localize('key', 'value');
|
|
105
|
-
nls.localize('key/nested', 'value');
|
|
103
|
+
const content = `
|
|
104
|
+
nls.localize('key', 'value');
|
|
105
|
+
nls.localize('key/nested', 'value');
|
|
106
106
|
`.trim();
|
|
107
107
|
const errors = [];
|
|
108
108
|
assert.deepStrictEqual(await (0, localization_extractor_1.extractFromFile)(TEST_FILE, content, errors, quiet), {
|
|
@@ -113,9 +113,9 @@ describe('correctly extracts from file content', () => {
|
|
|
113
113
|
]);
|
|
114
114
|
});
|
|
115
115
|
it('should show error when trying to merge a string into an object', async () => {
|
|
116
|
-
const content = `
|
|
117
|
-
nls.localize('key/nested', 'value');
|
|
118
|
-
nls.localize('key', 'value');
|
|
116
|
+
const content = `
|
|
117
|
+
nls.localize('key/nested', 'value');
|
|
118
|
+
nls.localize('key', 'value');
|
|
119
119
|
`.trim();
|
|
120
120
|
const errors = [];
|
|
121
121
|
assert.deepStrictEqual(await (0, localization_extractor_1.extractFromFile)(TEST_FILE, content, errors, quiet), {
|
|
@@ -11,9 +11,9 @@ export type LocalizationFunction = (parameters: DeeplParameters) => Promise<stri
|
|
|
11
11
|
export declare class LocalizationManager {
|
|
12
12
|
private localizationFn;
|
|
13
13
|
constructor(localizationFn?: typeof deepl);
|
|
14
|
-
localize(options: LocalizationOptions): Promise<
|
|
14
|
+
localize(options: LocalizationOptions): Promise<boolean>;
|
|
15
15
|
protected translationFileName(original: string, language: string): string;
|
|
16
|
-
translateLanguage(source: Localization, target: Localization, targetLanguage: string, options: LocalizationOptions): Promise<
|
|
16
|
+
translateLanguage(source: Localization, target: Localization, targetLanguage: string, options: LocalizationOptions): Promise<boolean>;
|
|
17
17
|
protected addIgnoreTags(text: string): string;
|
|
18
18
|
protected removeIgnoreTags(text: string): string;
|
|
19
19
|
protected buildLocalizationMap(source: Localization, target: Localization): LocalizationMap;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localization-manager.d.ts","sourceRoot":"","sources":["../src/localization-manager.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,YAAY,EAAoB,MAAM,UAAU,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAiB,eAAe,
|
|
1
|
+
{"version":3,"file":"localization-manager.d.ts","sourceRoot":"","sources":["../src/localization-manager.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,YAAY,EAAoB,MAAM,UAAU,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAiB,eAAe,EAAyC,MAAM,aAAa,CAAC;AAE3G,MAAM,WAAW,mBAAmB;IAChC,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,MAAM,CAAA;IAClB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,eAAe,EAAE,MAAM,EAAE,CAAA;CAC5B;AAED,MAAM,MAAM,oBAAoB,GAAG,CAAC,UAAU,EAAE,eAAe,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;AAEtF,qBAAa,mBAAmB;IAEhB,OAAO,CAAC,cAAc;gBAAd,cAAc,eAAQ;IAEpC,QAAQ,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC;IAgD9D,SAAS,CAAC,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM;IAMnE,iBAAiB,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC;IA4B3I,SAAS,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAI7C,SAAS,CAAC,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAIhD,SAAS,CAAC,oBAAoB,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,GAAG,eAAe;CAoC9F;AAED,MAAM,WAAW,eAAe;IAC5B,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;CACnD"}
|
|
@@ -45,8 +45,10 @@ class LocalizationManager {
|
|
|
45
45
|
languages.push(targetLanguage);
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
if (languages.length
|
|
49
|
-
|
|
48
|
+
if (languages.length === 0) {
|
|
49
|
+
// No supported languages were found, default to all supported languages
|
|
50
|
+
console.log('No languages were specified, defaulting to all supported languages for VS Code');
|
|
51
|
+
languages.push(...deepl_api_1.defaultLanguages);
|
|
50
52
|
}
|
|
51
53
|
const existingTranslations = new Map();
|
|
52
54
|
for (const targetLanguage of languages) {
|
|
@@ -58,7 +60,8 @@ class LocalizationManager {
|
|
|
58
60
|
existingTranslations.set(targetLanguage, {});
|
|
59
61
|
}
|
|
60
62
|
}
|
|
61
|
-
await Promise.all(languages.map(language => this.translateLanguage(source, existingTranslations.get(language), language, options)));
|
|
63
|
+
const results = await Promise.all(languages.map(language => this.translateLanguage(source, existingTranslations.get(language), language, options)));
|
|
64
|
+
let result = results.reduce((acc, val) => acc && val, true);
|
|
62
65
|
for (const targetLanguage of languages) {
|
|
63
66
|
const targetPath = this.translationFileName(sourceFile, targetLanguage);
|
|
64
67
|
try {
|
|
@@ -67,8 +70,10 @@ class LocalizationManager {
|
|
|
67
70
|
}
|
|
68
71
|
catch {
|
|
69
72
|
console.error(chalk.red(`Error writing translated file to '${targetPath}'`));
|
|
73
|
+
result = false;
|
|
70
74
|
}
|
|
71
75
|
}
|
|
76
|
+
return result;
|
|
72
77
|
}
|
|
73
78
|
translationFileName(original, language) {
|
|
74
79
|
const directory = path.dirname(original);
|
|
@@ -93,13 +98,16 @@ class LocalizationManager {
|
|
|
93
98
|
map.localize(i, this.removeIgnoreTags(text));
|
|
94
99
|
});
|
|
95
100
|
console.log(chalk.green(`Successfully translated ${map.text.length} value${map.text.length > 1 ? 's' : ''} for language "${targetLanguage}"`));
|
|
101
|
+
return true;
|
|
96
102
|
}
|
|
97
103
|
catch (e) {
|
|
98
104
|
console.log(chalk.red(`Could not translate into language "${targetLanguage}"`), e);
|
|
105
|
+
return false;
|
|
99
106
|
}
|
|
100
107
|
}
|
|
101
108
|
else {
|
|
102
109
|
console.log(`No translation necessary for language "${targetLanguage}"`);
|
|
110
|
+
return true;
|
|
103
111
|
}
|
|
104
112
|
}
|
|
105
113
|
addIgnoreTags(text) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localization-manager.js","sourceRoot":"","sources":["../src/localization-manager.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;AAEhF,+BAA+B;AAC/B,+BAA+B;AAC/B,6BAA6B;AAC7B,qCAA0D;AAC1D,
|
|
1
|
+
{"version":3,"file":"localization-manager.js","sourceRoot":"","sources":["../src/localization-manager.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AA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C;CACJ;AAlID,kDAkIC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theia/localization-manager",
|
|
3
|
-
"version": "1.53.0-next.
|
|
3
|
+
"version": "1.53.0-next.55+d1a989a68c",
|
|
4
4
|
"description": "Theia localization manager API.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
"typescript": "~5.4.5"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@theia/ext-scripts": "1.
|
|
43
|
+
"@theia/ext-scripts": "1.53.0"
|
|
44
44
|
},
|
|
45
45
|
"nyc": {
|
|
46
46
|
"extends": "../../configs/nyc.json"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "d1a989a68c1b5ec1f9098e9126653c6346844769"
|
|
49
49
|
}
|
package/src/common.ts
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2021 TypeFox and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
export interface Localization {
|
|
18
|
-
[key: string]: string | Localization
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function sortLocalization(localization: Localization): Localization {
|
|
22
|
-
return Object.keys(localization).sort().reduce((result: Localization, key: string) => {
|
|
23
|
-
const value = localization[key];
|
|
24
|
-
result[key] = typeof value === 'string' ? value : sortLocalization(value);
|
|
25
|
-
return result;
|
|
26
|
-
}, {});
|
|
27
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2021 TypeFox and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
export interface Localization {
|
|
18
|
+
[key: string]: string | Localization
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function sortLocalization(localization: Localization): Localization {
|
|
22
|
+
return Object.keys(localization).sort().reduce((result: Localization, key: string) => {
|
|
23
|
+
const value = localization[key];
|
|
24
|
+
result[key] = typeof value === 'string' ? value : sortLocalization(value);
|
|
25
|
+
return result;
|
|
26
|
+
}, {});
|
|
27
|
+
}
|