monaco-editor icon indicating copy to clipboard operation
monaco-editor copied to clipboard

How to localize in esm?

Open magicds opened this issue 4 years ago • 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 ?

magicds avatar Jul 19 '19 07:07 magicds

+1

s97712 avatar Aug 05 '19 14:08 s97712

Have you found a solution?

s97712 avatar Aug 05 '19 14:08 s97712

@s97712 Just use the amd moudle to load the monaco-editor.

magicds avatar Aug 06 '19 00:08 magicds

I also need some localize example.

PunKHS avatar Sep 17 '19 15:09 PunKHS

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".

blutorange avatar Sep 18 '19 01:09 blutorange

You can use monaco-editor-esm-webpack-plugin to localize in esm. Thanks to @blutorange's mind, I write a plugin to solute it.

wang12124468 avatar Sep 28 '19 14:09 wang12124468

How did you solve it,i use the amd moudle to load the monaco-editor,but still english。need i set ”availableLanguages“?thankyou!

jevinpi avatar Dec 28 '19 10:12 jevinpi

@jevinpi For amd , You can refer to the official demo Monaco Editor Localization Sample, and also you can refer mine demo at line 96.

magicds avatar Dec 28 '19 12:12 magicds

@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.

jevinpi avatar Dec 29 '19 07:12 jevinpi

@wang12124468 I don't have any effect using this method (monaco-editor-esm-webpack-plugin)

peachtang avatar Mar 12 '21 02:03 peachtang

I find a way by using with esm copy-webpack-plugin demo it work for me

chanelnumberseven avatar Jul 05 '21 10:07 chanelnumberseven

问下vue-cli 项目怎么汉化

zoubeihua avatar Aug 29 '21 04:08 zoubeihua

@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.

请问你找到解决方法了吗?

izhangchao avatar Nov 29 '21 10:11 izhangchao

i used it in vite, can‘t useing , thank you anyway

ailongfei avatar Jan 11 '22 09:01 ailongfei

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

poerlang avatar Apr 13 '22 01:04 poerlang

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. https://github.com/suren-atoyan/monaco-loader/issues/40

Tnze avatar Jan 01 '24 13:01 Tnze

monaco-editor version 0.45.0 still has this problem using ESM. Any updates?

Zasa-san avatar Feb 15 '24 20:02 Zasa-san

monaco-editor 版本 0.45.0 在使用 ESM 时仍然存在此问题。有更新吗?

你目前解决了嘛?

xiaoxiaohuayu avatar Mar 29 '24 06:03 xiaoxiaohuayu

monaco-editor 版本 0.45.0 在使用 ESM 时仍然存在此问题。有更新吗?

你目前解决了嘛?

Just don't use ESM. You can import monaco editor as static resources.

Tnze avatar Mar 29 '24 07:03 Tnze

monaco-editor 版本 0.45.0 在使用 ESM 时仍然存在此问题。有更新吗?

你目前解决了嘛?

只是不要使用 ESM。您可以将 monaco 编辑器导入为静态资源。

Do you have any examples?

xiaoxiaohuayu avatar Mar 29 '24 07:03 xiaoxiaohuayu