mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
w: upgrade deps
This commit is contained in:
1 parent
47499bdcd6
commit
0824487342
19 files changed
+132
-88
No files matched your search
@@ -23,7 +23,7 @@ export function registerAction(editor, model, element) {
|
||||
if (element) {
|
||||
editor.addAction({
|
||||
id: 'submit-form',
|
||||
label: 'Use light',
|
||||
label: 'Submit',
|
||||
keybindings: [
|
||||
monaco.KeyMod.CtrlCmd | monaco.KeyCode.Enter,
|
||||
monaco.KeyMod.WinCtrl | monaco.KeyCode.Enter,
|
||||
@@ -31,7 +31,7 @@ export function registerAction(editor, model, element) {
|
||||
run: () => $(element).closest('form').submit(),
|
||||
});
|
||||
}
|
||||
editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyMod.Shift | monaco.KeyCode.KEY_P, () => {
|
||||
editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyMod.Shift | monaco.KeyCode.KeyP, () => {
|
||||
editor.getAction('editor.action.quickCommand').run();
|
||||
});
|
||||
loadFormatter().then(([loaded, format]) => {
|
||||
@@ -41,7 +41,7 @@ export function registerAction(editor, model, element) {
|
||||
label: 'Format Code',
|
||||
contextMenuOrder: 0,
|
||||
contextMenuGroupId: 'operation',
|
||||
keybindings: [monaco.KeyMod.Alt | monaco.KeyMod.Shift | monaco.KeyCode.KEY_F],
|
||||
keybindings: [monaco.KeyMod.Alt | monaco.KeyMod.Shift | monaco.KeyCode.KeyF],
|
||||
run: () => {
|
||||
if (!['cpp', 'c'].includes(model._languageIdentifier.language)) return;
|
||||
const [success, result] = format(editor.getValue(), `${UserContext.astyleOptions.trim()} mode=c`);
|
||||
@@ -49,7 +49,7 @@ export function registerAction(editor, model, element) {
|
||||
else Notification.warn(result);
|
||||
},
|
||||
});
|
||||
editor.addCommand(monaco.KeyMod.Alt | monaco.KeyMod.Shift | monaco.KeyCode.KEY_F, () => {
|
||||
editor.addCommand(monaco.KeyMod.Alt | monaco.KeyMod.Shift | monaco.KeyCode.KeyF, () => {
|
||||
editor.getAction('hydro.format').run();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/* eslint-disable camelcase */
|
||||
import en_GB from 'monaco-editor-nls/locale/en-gb.json';
|
||||
import zh_CN from 'monaco-editor-nls/locale/zh-hans.json';
|
||||
import zh_TW from 'monaco-editor-nls/locale/zh-hant.json';
|
||||
import ko from 'monaco-editor-nls/locale/ko.json';
|
||||
import i18n from 'vj/utils/i18n';
|
||||
|
||||
function _format(message, args) {
|
||||
let result;
|
||||
if (args.length === 0) {
|
||||
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 = {};
|
||||
|
||||
function find(path, message) {
|
||||
for (const key of Object.keys(CURRENT_LOCALE_DATA)) {
|
||||
if (!CURRENT_LOCALE_DATA[key]) continue;
|
||||
if (CURRENT_LOCALE_DATA[key][path] && en_GB[key][path] === message) {
|
||||
return CURRENT_LOCALE_DATA[key][path];
|
||||
}
|
||||
}
|
||||
for (const key of Object.keys(CURRENT_LOCALE_DATA)) {
|
||||
if (!CURRENT_LOCALE_DATA[key]) continue;
|
||||
if (CURRENT_LOCALE_DATA[key][path]) {
|
||||
return CURRENT_LOCALE_DATA[key][path];
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
export function localize(path, message, ...args) {
|
||||
return _format(find(path.key || path, message), args);
|
||||
}
|
||||
|
||||
export function setLocaleData(data) {
|
||||
CURRENT_LOCALE_DATA = data;
|
||||
}
|
||||
|
||||
export function loadMessageBundle(file) {
|
||||
return localize;
|
||||
}
|
||||
|
||||
export function config(opt) {
|
||||
return loadMessageBundle;
|
||||
}
|
||||
|
||||
const languages = {
|
||||
zh_CN,
|
||||
zh_TW,
|
||||
ko,
|
||||
};
|
||||
if (languages[i18n('timeago_locale')]) setLocaleData(languages[i18n('timeago_locale')]);
|
||||
Reference in new issue
Block a user