Skip to content

Commit 6913978

Browse files
committed
Implement internationalization support
1 parent 31f78ef commit 6913978

File tree

27 files changed

+827
-158
lines changed

27 files changed

+827
-158
lines changed

dev-packages/application-manager/src/generator/frontend-generator.ts

Lines changed: 41 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -68,49 +68,57 @@ export class FrontendGenerator extends AbstractGenerator {
6868
}
6969

7070
protected compileIndexJs(frontendModules: Map<string, string>): string {
71-
return `// @ts-check
71+
const compiledModuleImports = this.compileFrontendModuleImports(frontendModules)
72+
// fix the generated indentation
73+
.replace(/^ /g, ' ');
74+
return `\
75+
// @ts-check
7276
${this.ifBrowser("require('es6-promise/auto');")}
7377
require('reflect-metadata');
7478
require('setimmediate');
7579
const { Container } = require('inversify');
7680
const { FrontendApplicationConfigProvider } = require('@theia/core/lib/browser/frontend-application-config-provider');
77-
FrontendApplicationConfigProvider.set(${this.prettyStringify(this.pck.props.frontend.config)});
78-
const { FrontendApplication } = require('@theia/core/lib/browser');
79-
const { frontendApplicationModule } = require('@theia/core/lib/browser/frontend-application-module');
80-
const { messagingFrontendModule } = require('@theia/core/lib/${this.pck.isBrowser()
81-
? 'browser/messaging/messaging-frontend-module'
82-
: 'electron-browser/messaging/electron-messaging-frontend-module'}');
83-
const { loggerFrontendModule } = require('@theia/core/lib/browser/logger-frontend-module');
84-
const { ThemeService } = require('@theia/core/lib/browser/theming');
85-
86-
const container = new Container();
87-
container.load(frontendApplicationModule);
88-
container.load(messagingFrontendModule);
89-
container.load(loggerFrontendModule);
9081
91-
function load(raw) {
92-
return Promise.resolve(raw.default).then(module =>
93-
container.load(module)
94-
)
95-
}
82+
FrontendApplicationConfigProvider.set(${this.prettyStringify(this.pck.props.frontend.config)});
9683
97-
function start() {
98-
(window['theia'] = window['theia'] || {}).container = container;
84+
const { ThemeService } = require('@theia/core/lib/browser/theming');
85+
ThemeService.get().loadUserTheme();
9986
100-
const themeService = ThemeService.get();
101-
themeService.loadUserTheme();
87+
const nls = require('@theia/core/lib/browser/nls');
10288
103-
const application = container.get(FrontendApplication);
104-
return application.start();
105-
}
89+
// nls translations MUST be loaded before requiring any code that uses them
90+
module.exports = nls.loadTranslations().then(() => {
91+
const { FrontendApplication } = require('@theia/core/lib/browser');
92+
const { frontendApplicationModule } = require('@theia/core/lib/browser/frontend-application-module');
93+
const { messagingFrontendModule } = require('@theia/core/lib/${this.pck.isBrowser()
94+
? 'browser/messaging/messaging-frontend-module'
95+
: 'electron-browser/messaging/electron-messaging-frontend-module'}');
96+
const { loggerFrontendModule } = require('@theia/core/lib/browser/logger-frontend-module');
97+
98+
const container = new Container();
99+
container.load(frontendApplicationModule);
100+
container.load(messagingFrontendModule);
101+
container.load(loggerFrontendModule);
102+
103+
return Promise.resolve()${compiledModuleImports}
104+
.then(start).catch(reason => {
105+
console.error('Failed to start the frontend application.');
106+
if (reason) {
107+
console.error(reason);
108+
}
109+
});
110+
111+
function load(jsModule) {
112+
return Promise.resolve(jsModule.default)
113+
.then(containerModule => container.load(containerModule));
114+
}
106115
107-
module.exports = Promise.resolve()${this.compileFrontendModuleImports(frontendModules)}
108-
.then(start).catch(reason => {
109-
console.error('Failed to start the frontend application.');
110-
if (reason) {
111-
console.error(reason);
112-
}
113-
});`;
116+
function start() {
117+
(window['theia'] = window['theia'] || {}).container = container;
118+
return container.get(FrontendApplication).start();
119+
}
120+
});
121+
`;
114122
}
115123

116124
protected compileElectronMain(electronMainModules?: Map<string, string>): string {

packages/callhierarchy/src/browser/callhierarchy-contribution.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,23 @@
1515
********************************************************************************/
1616

1717
import { injectable, inject } from '@theia/core/shared/inversify';
18-
import { MenuModelRegistry, Command, CommandRegistry } from '@theia/core/lib/common';
18+
import { MenuModelRegistry, CommandRegistry, Command } from '@theia/core/lib/common';
1919
import { AbstractViewContribution, OpenViewArguments, KeybindingRegistry } from '@theia/core/lib/browser';
2020
import { EDITOR_CONTEXT_MENU } from '@theia/editor/lib/browser';
2121
import { CallHierarchyTreeWidget } from './callhierarchy-tree/callhierarchy-tree-widget';
2222
import { CALLHIERARCHY_ID } from './callhierarchy';
2323
import { CurrentEditorAccess } from './current-editor-access';
2424
import { CallHierarchyServiceProvider } from './callhierarchy-service';
2525
import URI from '@theia/core/lib/common/uri';
26+
import { nls } from '@theia/core/lib/browser/nls';
2627

2728
export const CALL_HIERARCHY_TOGGLE_COMMAND_ID = 'callhierarchy:toggle';
2829
export const CALL_HIERARCHY_LABEL = 'Call Hierarchy';
2930

3031
export namespace CallHierarchyCommands {
3132
export const OPEN: Command = {
3233
id: 'callhierarchy:open',
33-
label: 'Open Call Hierarchy'
34+
label: nls.localize('callHierarchy.open', 'Open Call Hierarchy')
3435
};
3536
}
3637

packages/core/i18n/nls.de.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"file.download": "Herunterladen",
3+
"file.copyDownloadLink": "Link zum Herunterladen kopieren",
4+
"file.duplicate": "Duplizieren",
5+
"callHierarchy.open": "Call-Hierarchy öffnen",
6+
"core.nextTabInGroup": "Nächster Tab in der Gruppe",
7+
"core.previousTabInGroup": "Vorheriger Tab in der Gruppe",
8+
"core.nextTabGroup": "Nächste Tab-Gruppe",
9+
"core.previousTabBar": "Vorherige Tab-Gruppe",
10+
"core.close.tab": "Registerkarte schließen",
11+
"core.close.other.tabs": "Andere Registerkarten schließen",
12+
"core.close.right.tabs": "Registerkarten nach rechts schließen",
13+
"core.close.all.tabs": "Alle Registerkarten schließen",
14+
"core.close.main.tab": "Registerkarte im Hauptbereich schließen",
15+
"core.close.other.main.tabs": "Andere Registerkarten im Hauptbereich schließen",
16+
"core.close.all.main.tabs": "Alle Registerkarten im Hauptbereich schließen",
17+
"core.collapse.tab": "Panel zusammenklappen",
18+
"core.collapse.all.tabs": "Alle Panels zusammenklappen",
19+
"core.toggle.bottom.panel": "Panel im unteren Bereich öffnen",
20+
"core.toggleMaximized": "Maximieren",
21+
"i18n.configureLanguage": "Sprache wählen"
22+
}

packages/core/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@
114114
]
115115
},
116116
"theiaExtensions": [
117+
{
118+
"frontend": "lib/browser/i18n/i18n-frontend-module",
119+
"backend": "lib/node/i18n/i18n-backend-module"
120+
},
117121
{
118122
"frontend": "lib/browser/menu/browser-menu-module",
119123
"frontendElectron": "lib/electron-browser/menu/electron-menu-module"

0 commit comments

Comments
 (0)