Skip to content

Commit

Permalink
Allow to configure default locale (#10956)
Browse files Browse the repository at this point in the history
  • Loading branch information
msujew authored Mar 30, 2022
1 parent b087d58 commit ee9a071
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
10 changes: 9 additions & 1 deletion dev-packages/application-package/src/application-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ export namespace FrontendApplicationConfig {
applicationName: 'Eclipse Theia',
defaultTheme: 'dark',
defaultIconTheme: 'none',
electron: ElectronFrontendApplicationConfig.DEFAULT
electron: ElectronFrontendApplicationConfig.DEFAULT,
defaultLocale: ''
};
export interface Partial extends ApplicationConfig {

Expand Down Expand Up @@ -95,6 +96,13 @@ export namespace FrontendApplicationConfig {
* Defaults to `ElectronFrontendApplicationConfig.DEFAULT`.
*/
readonly electron?: ElectronFrontendApplicationConfig.Partial;

/**
* The default locale for the application.
*
* Defaults to "".
*/
readonly defaultLocale?: string;
}
}

Expand Down
7 changes: 7 additions & 0 deletions packages/core/src/browser/nls-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,15 @@

import { nls } from '../common/nls';
import { Endpoint } from './endpoint';
import { FrontendApplicationConfigProvider } from './frontend-application-config-provider';

export async function loadTranslations(): Promise<void> {
const defaultLocale = FrontendApplicationConfigProvider.get().defaultLocale;
if (defaultLocale && !nls.locale) {
Object.assign(nls, {
locale: defaultLocale
});
}
if (nls.locale) {
const endpoint = new Endpoint({ path: '/i18n/' + nls.locale }).getRestUrl().toString();
const response = await fetch(endpoint);
Expand Down

0 comments on commit ee9a071

Please sign in to comment.