Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>I18n Inline Tool for VSCodeNew to Visual Studio Code? Get it now.
I18n Inline Tool for VSCode

I18n Inline Tool for VSCode

keke.qiu

|
181 installs
| (2) | Free
A i18n tool for inline annotations and auto completions
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

I18n Inline Tool for VSCode

I18n Inline Tool for VSCode

VS Marketplace Version VS Marketplace Installs VS Marketplace Rating

An extension for Visual Studio Code that adds inline annotations and auto completions when calling $t

Example of I18n Inline Tool

I18n Inline Tool provides additional context of JetBrains' IDEs style for your internationalized code. By displaying inline internationalized translations, it makes it easier to read complex internationalized keywords; Through code completions, we no longer need to look up the international dictionary.

Configurations

Click the extension icon in the lower left corner of the status bar , it will open .i18ninlinerc file, the i18n prompt function can be enabled in the following three ways.

1. Specify local i18n files in your project

Configure i18nFiles like this:

{
  "i18nFiles": {
    "zh_cn": "src/lang/cn.js",
    // or multi files
    "en_us": ["src/lang/en.js", "../other-project/src/lang/en.js"]
  } 
}

language file schema:

export default {
  "lang.wms.fed.hello": "你好",
  // ...
}

2. Specify outside i18n file path

Configure jsonDataPath as a local path:

{
  "jsonDataPath": "/path/to/data.json",
  "i18nKeys": ["zh_cn"]
}

file schema:

{
  "lang.wms.fed.hello": {
    "zh_cn": "你好",
    // ...
  }
}

3. Configure MySQL database connection

Configure db connection information:

{
  "db": {
    "host": "0.0.0.0",
    "username": "readonly",
    "password": "readonly",
    "database": "database",
    "table": "i18n table name"
  },
  "i18nKeys": [],
  "key": "lang_code"
}

db.host supports reading environment variables by specifying the environment variable db.readHostFromEnv in .env or .env.development file.

For example, in vue projects, specify the environment variable as VUE_APP_BASE_URL

Configuration Field Details

Name Description
i18nFiles I18n file path in your project
jsonDataPath Local i18n file path
db MySQL database connection, extension reads remote i18n data and caches it locally
i18nKeys Internationalized list, such as zh_cn,en_us
key Internationalized entry keyword
traverse Traversal function, (list, cb (i18nKey, key, value) => {}), see example 2 below for details
validateKey Internationalized entry validation conditions. Filter the entries used in the front end through validateKey

Configuration example

  1. For example, we have an international table structure as follows:

t_i18n_language

id lang_code zh_cn en_us
1 lang.wms.fed.hello 你好 hello

Your international configuration should be as follows:

{
  "db": {
    "host": "0.0.0.0",
    "username": "readonly",
    "password": "readonly",
    "database": "database",
    "table": "t_i18n_language"
  },
  "i18nKeys": ["zh_cn", "en_us"],
  "key": "lang_code"
}
  1. For example, we have an international table structure as follows:

t_chaos_i18n_language

id lang_code item_code item_value
1 zh_cn lang.wms.fed.hello 你好
2 en_us lang.wms.fed.hello hello

Your international configuration should be as follows:

{
  "db": {
    "host": "0.0.0.0",
    "username": "readonly",
    "password": "readonly",
    "database": "database",
    "table": "t_chaos_i18n_language"
  },
  "i18nKeys": ["zh_cn", "en_us"],
  "traverse": "(list, cb) => list.forEach(item => cb(item['language_code'], item['item_code'], item['item_value']))",
}

Example of a complete configuration:

{
  "i18nFiles": {
    "zh_cn": "src/i18n/lang/cn.js",
    "en_us": "src/i18n/lang/en.js"
  },
  // or
  "jsonDataPath": "/path/to/data.json",
  // or
  "db": {
    "host": "0.0.0.0",
    // or
    "readHostFromEnv":  "VUE_APP_BASE_URL",
    "username": "readonly",
    "password": "readonly",
    "database": "database",
    "table": "i18n table name"
  },
  "i18nKeys": [
    "zh_cn",
    "en_us",
    "zh_hk"
  ],
  "key": "lang_code",
  "validateKey": "lang\\.\\w+\\.fed"
}

Settings

The extension provides a handful of configuration settings you can use to customise the look and behaviour of the parameters.

Name Description Default
i18n-inline-tool.enabled Toggle inline annotations and auto completions true
i18n-inline-tool.lang Current language zh_cn
i18n-inline-tool.autodownload Auto download when configuration changes false

There are also a handful of settings that can be used to customise the styling of the annotation to your own personal preference.

Name Description Default
i18n-inline-tool.fontWeight Annotation styling of font-weight CSS property "400"
i18n-inline-tool.fontStyle Annotation styling of font-style CSS property "italic"
i18n-inline-tool.fontSize Annotation styling of font size CSS property 0.85em
i18n-inline-tool.margin Annotation styling of margin CSS property 0.25em
i18n-inline-tool.padding Annotation styling of padding CSS property 0.25em 0.5em
i18n-inline-tool.border Annotation styling of border CSS property none
i18n-inline-tool.borderRadius Annotation styling of border-radius CSS property 0.25em

Themable Colours

You can change the default foreground and background colours in the workbench.colorCustomizations property in user settings.

Name Description
inlinetranslation.annotationForeground Specifies the foreground colour for the annotations
inlinetranslation.annotationBackground Specifies the background colour for the annotations

Commands

Name Description
i18n-inline-tool.toggle Enable / Disable i18n inline tool
i18n-inline-tool.open Open i18n inline tool .i18ninlinerc file
i18n-inline-tool.refresh Refresh local i18n data

Credits / Links

  • VSCode's Extension Samples, which was a huge help to get started
  • Liam Hammett for the Inline Parameters for VSCode (An extension for Visual Studio Code that adds inline parameter annotations when calling a function.)

License

The MIT License (MIT). Please see the license file for more information.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft