timkendrick / monaco-editor

CommonJS/Webpack compatible Monaco editor
MIT License
60 stars 7 forks source link

Different languages for the editor #4

Open MSeifert04 opened 6 years ago

MSeifert04 commented 6 years ago

The monaco editor (and vscode) does support multiple languages (like french, german, etc.), however it seems like the bundled editor here is english-only.

Is there anything I've been missing? Or is your monaco-editor or monaco-editor-loader package customizable in a way that allows to bundle multiple languages or a different language?

timkendrick commented 6 years ago

Hi there – I only really made this as a proof of concept, so I haven't properly looked into how localization works in monaco. Short answer: localization isn't supported in this package (yet…)

Long answer:

If you want to get your hands dirty, I'd guess that you can probably build translated versions by adding a vs/nls entry to the webpack resolve.alias setting (defined in webpack/createConfig.js). You could use this to provide a mock version of vs/nls that implements a localize() method which is pre-bound to return strings from the correct language.

I'm not entirely sure how the alternate language strings are generated – I think it's part of the vscode gulp build process (submodules/vscode/build/lib/nls.js) but it looks a bit fiddly. My webpack version uses a totally different build process, so those files won't be generated – however it looks like you might be able to grab pre-built versions of the strings for different languages in the monaco-editor npm package, in dev/vs/editor/editor.main.nls.[lang].js.

If you manage to get localization working, let me know how you did it and I'll try to integrate it into this package!

MSeifert04 commented 6 years ago

Thank you for the answer.

I haven't been able to get the translations yet. I'll let you know if I find a way but currently that's not really a priority - it would just be nice to have.

timkendrick commented 6 years ago

Yep – I plan to get round to this at some point, so I'll keep this issue open.

tom-s commented 5 years ago

Hi, anybody managed to get localization working ?