microsoft / monaco-editor

A browser based code editor
https://microsoft.github.io/monaco-editor/
MIT License
40.17k stars 3.58k forks source link

Example of how to load monaco editor with different language #2720

Open mheavenor opened 6 years ago

mheavenor commented 6 years ago

Is there any example of how to load the monaco editor with different languages besides English?

I found an old comment by alexandrudima referencing the following example but the example is for AMD:

https://github.com/Microsoft/monaco-editor-samples/blob/master/browser-amd-localized/index.html.

I am currently using the JSON worker and I would like messages like "Trailing comma" localized.

ludohenin commented 6 years ago

I second @mheavenor, would be really nice to have an example on how to do that.

alexdima commented 6 years ago

The editor is localized, but I don't think JSON is localized, so the error message would still come up in English.

mheavenor commented 6 years ago

I see that the JSON worker calls localize() in fillers/vscode-nls.js with the key and message but the key is never used. Are there plans to provide localization files for the messages within the JSON worker and use the key argument?

tom-s commented 5 years ago

Hi, has anybody found how to provide a locale for the editor (which sounds like it should be localized already ?) ? It's always in English

Lzw2016 commented 5 years ago

I need i18n example

dzcpy commented 4 years ago

It's been almost 2 years now. Anyone's found anything?

undefined-moe commented 3 years ago

Still no workarounds?

zamber commented 3 years ago

For anyone interested, there is a way to translate monaco-editor: https://github.com/wang12124468/monaco-editor-esm-webpack-plugin

The localize function in monaco-editor-nls may need patching to support strings with variables (at lest to work with 0.21.0) but besides that it works.