Skip to content

Commit 6176e50

Browse files
author
Alberto Iannaccone
authored
Enable language packs (#941)
* install language packs * register localization contribution to backend module * copy i18n folder to build * fix chinese language iid
1 parent 46a3466 commit 6176e50

File tree

7 files changed

+173
-7
lines changed

7 files changed

+173
-7
lines changed

arduino-ide-extension/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
"description": "An extension for Theia building the Arduino IDE",
55
"license": "AGPL-3.0-or-later",
66
"scripts": {
7-
"prepare": "yarn download-cli && yarn download-fwuploader && yarn download-ls && yarn copy-serial-plotter && yarn clean && yarn download-examples && yarn build && yarn test",
7+
"prepare": "yarn download-cli && yarn download-fwuploader && yarn download-ls && yarn copy-serial-plotter && yarn copy-i18n && yarn clean && yarn download-examples && yarn build && yarn test",
88
"clean": "rimraf lib",
99
"compose-changelog": "node ./scripts/compose-changelog.js",
1010
"download-cli": "node ./scripts/download-cli.js",
1111
"download-fwuploader": "node ./scripts/download-fwuploader.js",
1212
"copy-serial-plotter": "npx ncp ../node_modules/arduino-serial-plotter-webapp ./build/arduino-serial-plotter-webapp",
13+
"copy-i18n": "npx ncp ../i18n ./build/i18n",
1314
"download-ls": "node ./scripts/download-ls.js",
1415
"download-examples": "node ./scripts/download-examples.js",
1516
"generate-protocol": "node ./scripts/generate-protocol.js",

arduino-ide-extension/src/browser/contributions/add-zip-library.ts

-4
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ export class AddZipLibrary extends SketchContribution {
3939
...ArduinoMenus.SKETCH__UTILS_GROUP,
4040
'0_include',
4141
];
42-
// TODO: do we need it? calling `registerSubmenu` multiple times is noop, so it does not hurt.
43-
registry.registerSubmenu(includeLibMenuPath, 'Include Library', {
44-
order: '1',
45-
});
4642
registry.registerMenuAction([...includeLibMenuPath, '1_install'], {
4743
commandId: AddZipLibrary.Commands.ADD_ZIP_LIBRARY.id,
4844
label: nls.localize('arduino/library/addZip', 'Add .ZIP Library...'),

arduino-ide-extension/src/node/arduino-ide-backend-module.ts

+4
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ import { ArduinoFirmwareUploaderImpl } from './arduino-firmware-uploader-impl';
9292
import { PlotterBackendContribution } from './plotter/plotter-backend-contribution';
9393
import WebSocketServiceImpl from './web-socket/web-socket-service-impl';
9494
import { WebSocketService } from './web-socket/web-socket-service';
95+
import { ArduinoLocalizationContribution } from './arduino-localization-contribution';
96+
import { LocalizationContribution } from '@theia/core/lib/node/i18n/localization-contribution';
9597

9698
export default new ContainerModule((bind, unbind, isBound, rebind) => {
9799
bind(BackendApplication).toSelf().inSingletonScope();
@@ -340,4 +342,6 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
340342

341343
bind(PlotterBackendContribution).toSelf().inSingletonScope();
342344
bind(BackendApplicationContribution).toService(PlotterBackendContribution);
345+
bind(ArduinoLocalizationContribution).toSelf().inSingletonScope();
346+
bind(LocalizationContribution).toService(ArduinoLocalizationContribution);
343347
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
import {
2+
LocalizationContribution,
3+
LocalizationRegistry,
4+
} from '@theia/core/lib/node/i18n/localization-contribution';
5+
import { injectable } from 'inversify';
6+
7+
@injectable()
8+
export class ArduinoLocalizationContribution
9+
implements LocalizationContribution
10+
{
11+
async registerLocalizations(registry: LocalizationRegistry): Promise<void> {
12+
registry.registerLocalizationFromRequire(
13+
'af',
14+
require('../../build/i18n/af.json')
15+
);
16+
17+
registry.registerLocalizationFromRequire(
18+
'en',
19+
require('../../build/i18n/en.json')
20+
);
21+
22+
registry.registerLocalizationFromRequire(
23+
'fr',
24+
require('../../build/i18n/fr.json')
25+
);
26+
27+
registry.registerLocalizationFromRequire(
28+
'ko',
29+
require('../../build/i18n/ko.json')
30+
);
31+
32+
registry.registerLocalizationFromRequire(
33+
'pt',
34+
require('../../build/i18n/pt.json')
35+
);
36+
37+
registry.registerLocalizationFromRequire(
38+
'uk_UA',
39+
require('../../build/i18n/uk_UA.json')
40+
);
41+
42+
registry.registerLocalizationFromRequire(
43+
'ar',
44+
require('../../build/i18n/ar.json')
45+
);
46+
47+
registry.registerLocalizationFromRequire(
48+
'es',
49+
require('../../build/i18n/es.json')
50+
);
51+
52+
registry.registerLocalizationFromRequire(
53+
'he',
54+
require('../../build/i18n/he.json')
55+
);
56+
57+
registry.registerLocalizationFromRequire(
58+
'my_MM',
59+
require('../../build/i18n/my_MM.json')
60+
);
61+
62+
registry.registerLocalizationFromRequire(
63+
'ro',
64+
require('../../build/i18n/ro.json')
65+
);
66+
67+
registry.registerLocalizationFromRequire(
68+
'zh-cn',
69+
require('../../build/i18n/zh.json')
70+
);
71+
72+
registry.registerLocalizationFromRequire(
73+
'bg',
74+
require('../../build/i18n/bg.json')
75+
);
76+
77+
registry.registerLocalizationFromRequire(
78+
'eu',
79+
require('../../build/i18n/eu.json')
80+
);
81+
82+
registry.registerLocalizationFromRequire(
83+
'hu',
84+
require('../../build/i18n/hu.json')
85+
);
86+
87+
registry.registerLocalizationFromRequire(
88+
'ne',
89+
require('../../build/i18n/ne.json')
90+
);
91+
92+
registry.registerLocalizationFromRequire(
93+
'ru',
94+
require('../../build/i18n/ru.json')
95+
);
96+
97+
registry.registerLocalizationFromRequire(
98+
'zh_TW',
99+
require('../../build/i18n/zh_TW.json')
100+
);
101+
102+
registry.registerLocalizationFromRequire(
103+
'de',
104+
require('../../build/i18n/de.json')
105+
);
106+
107+
registry.registerLocalizationFromRequire(
108+
'fa',
109+
require('../../build/i18n/fa.json')
110+
);
111+
112+
registry.registerLocalizationFromRequire(
113+
'it',
114+
require('../../build/i18n/it.json')
115+
);
116+
117+
registry.registerLocalizationFromRequire(
118+
'nl',
119+
require('../../build/i18n/nl.json')
120+
);
121+
122+
registry.registerLocalizationFromRequire(
123+
'sv_SE',
124+
require('../../build/i18n/sv_SE.json')
125+
);
126+
127+
registry.registerLocalizationFromRequire(
128+
'el',
129+
require('../../build/i18n/el.json')
130+
);
131+
132+
registry.registerLocalizationFromRequire(
133+
'fil',
134+
require('../../build/i18n/fil.json')
135+
);
136+
137+
registry.registerLocalizationFromRequire(
138+
'ja',
139+
require('../../build/i18n/ja.json')
140+
);
141+
142+
registry.registerLocalizationFromRequire(
143+
'pl',
144+
require('../../build/i18n/pl.json')
145+
);
146+
147+
registry.registerLocalizationFromRequire(
148+
'tr',
149+
require('../../build/i18n/tr.json')
150+
);
151+
}
152+
}

electron/build/template-package.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,12 @@
151151
"vscode-arduino-tools": "https://downloads.arduino.cc/vscode-arduino-tools/vscode-arduino-tools-0.0.2-beta.2.vsix",
152152
"vscode-builtin-json": "https://open-vsx.org/api/vscode/json/1.46.1/file/vscode.json-1.46.1.vsix",
153153
"vscode-builtin-json-language-features": "https://open-vsx.org/api/vscode/json-language-features/1.46.1/file/vscode.json-language-features-1.46.1.vsix",
154-
"cortex-debug": "https://open-vsx.org/api/marus25/cortex-debug/0.3.10/file/marus25.cortex-debug-0.3.10.vsix"
154+
"cortex-debug": "https://open-vsx.org/api/marus25/cortex-debug/0.3.10/file/marus25.cortex-debug-0.3.10.vsix",
155+
"vscode-language-pack-nl": "https://open-vsx.org/api/MS-CEINTL/vscode-language-pack-nl/1.48.3/file/MS-CEINTL.vscode-language-pack-nl-1.48.3.vsix",
156+
"vscode-language-pack-fr": "https://open-vsx.org/api/MS-CEINTL/vscode-language-pack-fr/1.53.2/file/MS-CEINTL.vscode-language-pack-fr-1.53.2.vsix",
157+
"vscode-language-pack-zh-hans": "https://open-vsx.org/api/MS-CEINTL/vscode-language-pack-zh-hans/1.53.2/file/MS-CEINTL.vscode-language-pack-zh-hans-1.53.2.vsix",
158+
"vscode-language-pack-de": "https://open-vsx.org/api/MS-CEINTL/vscode-language-pack-de/1.53.2/file/MS-CEINTL.vscode-language-pack-de-1.53.2.vsix",
159+
"vscode-language-pack-ja":"https://open-vsx.org/api/MS-CEINTL/vscode-language-pack-ja/1.53.2/file/MS-CEINTL.vscode-language-pack-ja-1.53.2.vsix",
160+
"vscode-language-pack-tr": "https://open-vsx.org/api/MS-CEINTL/vscode-language-pack-tr/1.53.2/file/MS-CEINTL.vscode-language-pack-tr-1.53.2.vsix"
155161
}
156162
}

electron/packager/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
'yarn.lock',
7575
'package.json',
7676
'lerna.json',
77+
'i18n'
7778
]) {
7879
cp('-rf', path(rootPath, name), path('..', workingCopy));
7980
}

package.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@
7474
"vscode-arduino-tools": "https://downloads.arduino.cc/vscode-arduino-tools/vscode-arduino-tools-0.0.2-beta.2.vsix",
7575
"vscode-builtin-json": "https://open-vsx.org/api/vscode/json/1.46.1/file/vscode.json-1.46.1.vsix",
7676
"vscode-builtin-json-language-features": "https://open-vsx.org/api/vscode/json-language-features/1.46.1/file/vscode.json-language-features-1.46.1.vsix",
77-
"cortex-debug": "https://open-vsx.org/api/marus25/cortex-debug/0.3.10/file/marus25.cortex-debug-0.3.10.vsix"
77+
"cortex-debug": "https://open-vsx.org/api/marus25/cortex-debug/0.3.10/file/marus25.cortex-debug-0.3.10.vsix",
78+
"vscode-language-pack-nl": "https://open-vsx.org/api/MS-CEINTL/vscode-language-pack-nl/1.48.3/file/MS-CEINTL.vscode-language-pack-nl-1.48.3.vsix",
79+
"vscode-language-pack-fr": "https://open-vsx.org/api/MS-CEINTL/vscode-language-pack-fr/1.53.2/file/MS-CEINTL.vscode-language-pack-fr-1.53.2.vsix",
80+
"vscode-language-pack-zh-hans": "https://open-vsx.org/api/MS-CEINTL/vscode-language-pack-zh-hans/1.53.2/file/MS-CEINTL.vscode-language-pack-zh-hans-1.53.2.vsix",
81+
"vscode-language-pack-de": "https://open-vsx.org/api/MS-CEINTL/vscode-language-pack-de/1.53.2/file/MS-CEINTL.vscode-language-pack-de-1.53.2.vsix",
82+
"vscode-language-pack-ja":"https://open-vsx.org/api/MS-CEINTL/vscode-language-pack-ja/1.53.2/file/MS-CEINTL.vscode-language-pack-ja-1.53.2.vsix",
83+
"vscode-language-pack-tr": "https://open-vsx.org/api/MS-CEINTL/vscode-language-pack-tr/1.53.2/file/MS-CEINTL.vscode-language-pack-tr-1.53.2.vsix"
7884
}
7985
}

0 commit comments

Comments
 (0)