mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
- Migrate entry points to the 0.57 exports scheme (monaco-editor/editor, languages/features/typescript/register) - Wire workers via the official MonacoEnvironment.getWorker + new Worker(new URL(...)) integration; webpack emits them as shared-chunk classic workers (chrome 70 compatible), total assets -21% - Keep css/html/json language features (register.all) and route their worker labels; json is used by the cmeditor textareas - Replace removed esm/vs/nls.messages with an inline implementation in the nls shim - Drop MinChunkSizePlugin: it merged worker chunks into the main chunk and broke the runtime id module (webpack#15416) - Remove monaco-editor-webpack-plugin dependency - loadMonaco() now returns the loaded feature module exports, e.g. loadMonaco(['typescript']).typescript.javascriptDefaults
38 lines
955 B
JavaScript
38 lines
955 B
JavaScript
export function getNLSLanguage() {
|
|
return globalThis._VSCODE_NLS_LANGUAGE;
|
|
}
|
|
|
|
export function getNLSMessages() {
|
|
return globalThis._VSCODE_NLS_MESSAGES || [];
|
|
}
|
|
|
|
function format(message, args) {
|
|
let result;
|
|
if (!args.length) result = message;
|
|
else {
|
|
result = String(message).replace(/\{(\d+)\}/g, (match, rest) => {
|
|
const index = rest[0];
|
|
return typeof args[index] !== 'undefined' ? args[index] : match;
|
|
});
|
|
}
|
|
return result;
|
|
}
|
|
|
|
let CURRENT_LOCALE_DATA = {}; // eslint-disable-line ts/naming-convention
|
|
|
|
export function localize(path, message, ...args) {
|
|
return format(CURRENT_LOCALE_DATA[path.key || path] || CURRENT_LOCALE_DATA[message] || message, args);
|
|
}
|
|
|
|
export function localize2(data, message, ...args) {
|
|
const original = localize(data, message, args);
|
|
return {
|
|
value: original,
|
|
original,
|
|
};
|
|
}
|
|
|
|
export function setLocaleData(data) {
|
|
CURRENT_LOCALE_DATA = Object.assign(...Object.values(data));
|
|
}
|