问题
I want to know how to change editor's locale?
eg: change en-us to zh-cn
This is for monaco-editor@0.17.1,vue@2.6.10
回答1:
安装monaco-editor-locales-plugin
npm instal -D monaco-editor-locales-plugin
weback配置
//引入插件
const MonacoLocalesPlugin = require('monaco-editor-locales-plugin');
new MonacoLocalesPlugin({
//设置支持的语言
languages: ["es","zh-cn"],
//默认语言
defaultLanguage: "zh-cn",
//打印不匹配的文本
logUnmatched: false,
//自定义文本翻译
mapLanguages: {"zh-cn": {"Peek References": "查找引用", "Go to Symbol...": "跳到变量位置", "Command Palette": "命令面板"}}
})
来源:https://stackoverflow.com/questions/57781013/how-to-change-the-monaco-editors-locale