๐ i18n helpers for Vue, React, Angular and more in VSCode
Vue i18n Ally
is now i18n Ally
!
- Multi-root workspace supported
- Remote development supported
- Supports both
vue-i18n
,vuex-i18n
,vue-i18next
andnuxt-i18n
- i18n for the extension itself, of course. (supporting: English, ็ฎไฝไธญๆ, ็น้ซไธญๆ or help us translate)
Frameworks will be auto detected when one of the dependencies can be found in the project.
Format | Manage | Annonations | Triggers | Note |
---|---|---|---|---|
Vue | โ | โ | vue-i18n , vuex-i18n , vue-i18next , nuxt-i18n |
|
React | โ | โ | react-i18next , react-intl |
|
General i18next | โ | โ | i18next and none of above |
Format | Read | Write | Annonations | Note |
---|---|---|---|---|
JSON | โ | โ | โ | |
YAML | โ | โ | โ | Comments will NOT preserved* |
JSON5 | โ | โ | โ | Comments will NOT preserved* |
JavaScript | โ | โ | โ | Forced in readonly mode |
TypeScript | โ | โ | โ | Forced in readonly mode |
* Due to the limitation of yaml.dumps
(#196) and JSON5.stringify
(#177), comments in YAML and JSON5 will be OMITTED on any modification by this extension (editing, translating, etc). If you are using comments in your locale files, you can turn on readonly mode by vue-i18n-ally.readonly
to prevent lossing comments.
You can have locales directory structured like this with zero-configuration
locales # i18n, langs, locale are also acceptable
โโโ en.json
โโโ de-DE.json
โโโ zh-CN.yml # YAML
โโโ zh-TW.ts # You can mix different formats
โโโ ...
โโโ <contry-code>.json
or
locales
โโโ en
| โโโ common.json
| โโโ buttons.json
| โโโ ...
| โโโ <filenames>.json
โโโ de-DE
| โโโ common.json
| โโโ buttons.json
| โโโ ...
โโโ <contry-code>
โโโ common.json
โโโ buttons.json
โโโ ...
All fields should add prefix "vue-i18n-ally.
" in the setting.
Field | Default | Description |
---|---|---|
sourceLanguage |
en |
The primary locale for the project. It will also be the source language on translating. |
displayLanguage |
en |
Displaying language in annotations and tree views. |
localesPaths |
Auto detect | Locales directory path, relative to root of the project. Can also be an array of paths. Glob patterns are acceptable. |
sortedKeys |
false |
Sorting keys alphabetically on saving |
readonly |
false |
Work on readonly mode. Translating and editing will be disabled. |
annotations |
true |
Enabling inline annotations |
Field | Default | Description |
---|---|---|
filenameMatchRegex |
null | Accept a regex allows you to map the filenames. The first group in regex should be the locale code. |
forceEnabled |
false |
Extension will on enabled when vue-i18n -ish dependencies is installed in the project. Turning on this option will force the extension enabled anyway. |
experimental.sfc |
false |
Support for loading Single File Components <i18n> section. Currently SFC only works in READONLY mode, the other features will be landed in future release. |
This extension itself supports i18n as well, it will be auto matched to the display language you used in your vscode editor. If you would like to help translate this extension, you can do it by following steps.
- Fork this repo and clone it to you local machine
- Copy
package.nls.json
topackage.nls.<locale-code>.json
in the root of the repo - Translate every single message in the new json file you created.
- Commit changes and make a PR to this repo
We would recommend you to use vscode with vue-i18n-ally
installed. It can helps you translate itself ๐, all the configs were already set in the workspace settings.
Extension will only be enabled on vue-i18n
"-ish" project. Make sure you have one of the following package in the dependencies
or devDependencies
fields of your package.json
- Locales path config missing.
locales
path will be detected automatically at the first time you open a project. If the nothing show up, you may need to configure it manually. There are two ways to do that:- Open Command Palette (
Ctrl-Shift-P
orโโงP
), typei18n Ally: Manual configure locales path
then press enter and follow the guide. - Goto to the settings of VSCode and set
vue-i18n-ally.localesPaths
manually.
- Open Command Palette (
- The source / displaying locale. The default locale is set to English(
en
). If you don't have English in your supporting locales, you may need to config it through commandi18n Ally: Change source language
- Check your Directory structure
In some cases, you may use modules, monorepo or other philosophies to organize your locale files.
For example, you have following directory structure need to be config.
packages
โโโ pkgA
| โโโ i18n
| โโโ en.messages.json
| โโโ zh-CN.messages.json
| โโโ ...
โโโ pkgB
| โโโ i18n
| โโโ en.messages.json
| โโโ zh-CN.messages.json
| โโโ ...
โโโ ...
You could change your config like this:
{
"vue-i18n-ally.localesPaths": [
"packages/**/**/i18n"
],
"vue-i18n-ally.filenameMatchRegex": "^([\\w-]*)\\.messages\\.json",
}
We have not determined schedule to implement the TODOs. If you would like to see them implemented, please open an issue and share your use cases. PR is also welcome.
Todo:
- Tests
- Live share support
-
esm
hot reloading, #97 - Enhance SFC support
Done:
- Machine translating
- Locales Tree
- Translating progress
- Workspace support
- YAML support
-
$tc
,$d
,$n
,v-t
support - Hide/Show specific locales
- Language flags
- Goto definition
- Source language indicator
- i18n for the plugin itself
- Annoation config (on/off, maxlength)
- Option to force enabling on non-vue-i18n project
- Find all references
- Loading
.js
locales - Loading
.ts
locales - Analysis report
- JSON/YAML file annonation & hint
- Single File Components i18n support
This extension is original forked from think2011/vscode-vue-i18n, it can't be existed without @think2011's great work.
And thanks for all the awesome contributors.
MIT License ยฉ 2019 Anthony Fu
MIT License ยฉ 2018-2019 think2011