forked from TypeFox/monaco-languageclient
-
Notifications
You must be signed in to change notification settings - Fork 0
/
localeLoader.ts
28 lines (26 loc) · 1.08 KB
/
localeLoader.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/* --------------------------------------------------------------------------------------------
* Copyright (c) 2024 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
export const loadLocales = async () => {
const locale = new URLSearchParams(window.location.search).get('locale');
const localeLoader: Partial<Record<string, () => Promise<void>>> = {
de: async () => {
await import('@codingame/monaco-vscode-language-pack-de');
},
es: async () => {
await import('@codingame/monaco-vscode-language-pack-es');
},
fr: async () => {
await import('@codingame/monaco-vscode-language-pack-fr');
}
};
if (locale !== null) {
const loader = localeLoader[locale];
if (loader) {
await loader();
} else {
console.error(`Unknown locale ${locale}`);
}
}
};