This repository has been archived by the owner on Oct 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nls.js
49 lines (43 loc) · 1.44 KB
/
nls.js
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
module.exports["localize"] = module.exports["loadMessageBundle"] = module.exports["config"] = null;
// This file is condensed from vscode-loc 1.63.3
const zhCN = require("dt-monaco-editor-nls-webpack-plugin/i18n/dt-zh-hans.json");
// replace monaco-editor/esm/vs/nls.js _format
function _format(message, args) {
let result;
if (args.length === 0) {
result = message;
} else {
result = String(message).replace(/\{(\d+)\}/g, function (match, rest) {
const index = rest[0];
return typeof args[index] !== "undefined" ? args[index] : match;
});
}
return result;
}
// replace monaco-editor/esm/vs/nls.js localize
function localize(path, data, defaultMessage) {
const key = typeof data === "object" ? data.key : data;
const _data = zhCN ? zhCN.contents : {};
let message = (_data[path] || {})[key];
if (!message) {
message = defaultMessage;
}
const args = [];
for (let _i = 3; _i < arguments.length; _i++) {
args[_i - 3] = arguments[_i];
}
return _format(message, args);
}
module.exports["localize"] = localize;
function loadMessageBundle(_file) {
return localize;
}
module.exports["loadMessageBundle"] = loadMessageBundle;
function config(_opt) {
return loadMessageBundle;
}
module.exports["config"] = config;
function getConfiguredDefaultLocale() {
return undefined;
}
module.exports["getConfiguredDefaultLocale"] = getConfiguredDefaultLocale;