How to localize in esm?
magicds opened this issue · 20 comments
monaco-editor version: 0.17.1
Browser:: Google Chrome 75.0.3770.142
OS: windows 10
I find an localization demo by using amd
Monaco Editor Localization Sample, but how can I make localization by using esm ? Is here any example ?
+1
Have you found a solution?
I also need some localize example.
There is a "solution" which I described here: https://github.com/blutorange/primefaces-monaco/blob/master/ESM-I18N.md Though I'm not quite sure whether it ought to be called it "solution", "hack", or "workaround".
You can use monaco-editor-esm-webpack-plugin to localize in esm.
Thanks to @blutorange's mind, I write a plugin to solute it.
How did you solve it,i use the amd moudle to load the monaco-editor,but still english。need i set ”availableLanguages“?thankyou!
@jevinpi For amd , You can refer to the official demo Monaco Editor Localization Sample, and also you can refer mine demo at line 96.
@jevinpi For amd , You can refer to the official demo Monaco Editor Localization Sample, and also you can refer mine demo at line 96.
i used it in React, can't use require.config to set vs/nls. thankyou anyway, i will try other methods.
@wang12124468 I don't have any effect using this method (monaco-editor-esm-webpack-plugin)
I find a way by using with esm
copy-webpack-plugin
demo
it work for me
问下vue-cli 项目怎么汉化
@jevinpi For amd , You can refer to the official demo Monaco Editor Localization Sample, and also you can refer mine demo at line 96.
i used it in React, can't use require.config to set vs/nls. thankyou anyway, i will try other methods.
请问你找到解决方法了吗?
i used it in vite, can‘t useing , thank you anyway
When you use vite + vue3 ,try this one:
https://www.npmjs.com/package/@monaco-editor/loader
it work for me.
config like below:
loader.config({ paths: { vs: 'monaco-editor/min/vs' } }); // copy monaco-editor from /node_modules to /public
loader.config({
'vs/nls': {
availableLanguages: { '*': 'de' }
// availableLanguages: { '*': 'zh-cn' }
}
})
@ailongfei @izhangchao
When you use vite + vue3 ,try this one:
https://www.npmjs.com/package/@monaco-editor/loader
it work for me.
config like below:
loader.config({ paths: { vs: 'monaco-editor/min/vs' } }); // copy monaco-editor from /node_modules to /public loader.config({ 'vs/nls': { availableLanguages: { '*': 'de' } // availableLanguages: { '*': 'zh-cn' } } })
@ailongfei @izhangchao
It works because it doesn't use ESM at all. It loads monaco-editor
from CDN by default.
It dose can load monaco from ESM, but in that case it doesn't support vs/nls
. suren-atoyan/monaco-loader#40
monaco-editor version 0.45.0 still has this problem using ESM. Any updates?
monaco-editor 版本 0.45.0 在使用 ESM 时仍然存在此问题。有更新吗?
你目前解决了嘛?
monaco-editor 版本 0.45.0 在使用 ESM 时仍然存在此问题。有更新吗?
你目前解决了嘛?
Just don't use ESM. You can import monaco editor as static resources.
monaco-editor 版本 0.45.0 在使用 ESM 时仍然存在此问题。有更新吗?
你目前解决了嘛?
只是不要使用 ESM。您可以将 monaco 编辑器导入为静态资源。
Do you have any examples?