npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

monaco-editor-i18n-plugin

v2.0.0

Published

A i18n plugin for the Monaco editor

Readme

monaco-editor-i18n-plugin

English | 简体中文

The purpose of this plugin is to set the interface language when using monaco-editor. The main implementation idea is to override the monaco-editor/esm/vs/nls.js file to achieve the effect of interface language switching.

Version difference

The main difference between 2.x and 1.x lies in the version of monaco-editor.

  • The 2.x: When your product needs to support internationalization (the product page supports switching interface languages), please use version 2.x. It has been verified with monaco-editor versions 0.52.2.
  • The 1.x: When your product needs to support internationalization (the product page supports switching interface languages), please use version 1.x. It has been verified with monaco-editor versions 0.30.1 and 0.31.1.
  • The 0.x: When your product only has one interface language (does not need to support internationalization, such as only supporting Chinese), please use version 0.x. It has been verified with monaco-editor versions 0.30.1 and 0.31.1.

Install

  • npm install monaco-editor-i18n-plugin -D

Languages

dt-zh-hans (Simplified version for dtstack)

The used src/locale/dt-zh-hans.json is lite based on vscode-loc/i18n/zh-hans.

Simplified Chinese (Full version)

The used src/locale/zh-hans.json is from vscode-loc/i18n/zh-hans

custom languages

If you want to use another languages or if the simplified src/scale/dt-zh-hans.json file does not meet the requirements, you can find JSON files in other languages in vscode-loc/i18n, and place them in your project folder for custom path usage.

Example usage

configuration item

const MonacoEditorI18nPlugin = require('monaco-editor-i18n-plugin');

const plugin = [
    ...,
    {
        key: 'WebpackPlugin',
        action: 'add',
        opts: {
            name: 'MonacoEditorI18nPlugin',
            fn: () => {
                return new MonacoEditorI18nPlugin({
                    windowKey: '__DT_LOCALE__',
                    localStorageKey: 'dt-locale',
                });
            },
        },
    }
]
  • webpack.config.js
const MonacoEditorI18nPlugin = require('monaco-editor-i18n-plugin');

module.exports = {
    ...,
    plugins: [
        new MonacoEditorI18nPlugin({
            windowKey: '__DT_LOCALE__',
            localStorageKey: 'dt-locale',
        })
    ],
    ...,
};

Instructions

The interface language content used needs to be mounted on the window object in the engineering code, with the default key value is __DT_LOCALE__. En US is the default language for monaco-editor, and a value of an empty object is sufficient. The subsequent reading of interface language content will be done from the window object. The mounting example is as follows:

import dtZhHans from 'monaco-editor-i18n-plugin/out/locale/dt-zh-hans.json';
import zhHant from './zh-hant.json';

// Mount the interface language content onto the window object
window.__DT_LOCALE__ = {
    'zh-hant': zhHant?.contents || {},
    'dt-zh-hans': dtZhHans?.contents || {},
    'en-US': {},
};

When switching interface languages, it is necessary to synchronize the language name to the localStorage. The switching example is as follows:

function setLocale(value: string) {
    window.localStorage.setItem('dt-locale', value);
}

setLocale('dt-zh-hans');

Important

  • If the interface language of monaco-editor does not change with the product page, please note that the mounting timing of window.__DT_LOCALE__ should be as early as possible.

Notice

  • The currently verified versions of monaco-editor are 0.52.2.
  • The corresponding version of vscode doc is 1.91.1.
  • If custom language doesn't work, it may be due to a mismatch between the versions of the two packages. The JSON file structure in later versions of vscode-loc has changed (like 1.63.3 and 1.91.1), Please verify other versions yourself.