Skip to content

alexdima/monaco-editor-localization

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Localizing the ESM distribution of monaco-editor

image

Running

npm install
node prepare.js
node build.js
npx serve -l tcp://127.0.0.1:3000
open http://127.0.0.1:3000/dist/

Explanation

  • This repository is based on the esbuild sample, but the prepare.js script should work for any other bundler.
  • The solution consists of scanning the /amd/ distribution of the monaco editor and creating a mapping from all English strings to translated strings.
  • Then, the monaco-editor/esm/vs/nls.js file is patched to contain all of these strings.
  • As a consumer of the editor, you need to define self.MONACO_LANGUAGE before loading the source code for the editor
    • Supported values: "de", "en", "es", "fr", "it", "ja", "ko", "ru", "zh-cn", "zh-tw"

What's the catch?

  • The catch is that this solution will bundle all languages used in the editor, so that is why this isn't the official solution. You can take inspiration from this sample and write your own nls.js script which matches the logic you have for localizing other parts of your code. Good luck!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors