Update: ace编辑器的多国语言支持

This commit is contained in:
王立帮
2025-03-22 08:59:27 +08:00
parent 8f96688184
commit dbc3a6af84
4 changed files with 98 additions and 0 deletions

View File

@@ -19,16 +19,24 @@ const {
EditorBase
} = Mixly;
class EditorAce extends EditorBase {
static {
this.CTRL_BTNS = ['resetFontSize', 'increaseFontSize', 'decreaseFontSize'];
this.CTRL_BTN_TEMPLATE = '<div m-id="{{d.mId}}" class="code-editor-btn setFontSize"></div>';
this.MODE_MAP = goog.getJSON(path.join(Env.templatePath, 'json/ace-mode-map.json'));
this.I18N = {
'zh-hans': goog.getJSON(path.join(Env.templatePath, 'json/ace-i18n-zh-hans.json')),
'zh-hant': goog.getJSON(path.join(Env.templatePath, 'json/ace-i18n-zh-hant.json')),
'en': goog.getJSON(path.join(Env.templatePath, 'json/ace-i18n-en.json'))
}
HTMLTemplate.add(
'html/editor/editor-code.html',
new HTMLTemplate(goog.get(path.join(Env.templatePath, 'html/editor/editor-code.html')))
);
ace.config.setMessages(this.I18N[Msg.nowLang]);
}
#editor_ = null;