i18n-converter
v0.1.2
Published
Convert editor json files with a given template into more complex vue-i18n json files
Downloads
72
Readme
i18n-converter
This converter helps to transfer translations received in an excel file to our i18n JSON-Files.
Installation
npm install i18n-converter
Usage
Your i18n files
Your translation files are separate json files for every market like this:
translations
├── DE.json
├── US.json
├── CA.json
├── GB.json
├── ES.json
├── FR.json
├── IT.json
└── MX.json
Your editor file
You need to add a file called EDITOR_FILE.json or EDITOR_FILE_EXCEL_COPY_PASTE to the directory where your translations are. Alternatively you can choose to use data that is in your clipboard. (copied from an excel file)
The script can use in two ways: ReplacementKeys or KeyPaths
ReplacementKeys
Your i18n files contain keys which are used as placeholders for translations. The script will replace the keys with the translations from the editor file.
KeyPaths
No preparation of your i18n-json file is needed. The editor file contains key paths where the translation has to be in the i18n files. The script will add the translations to the i18n files.
Editor file: Option 1: EDITOR_FILE.json
EDITOR_FILE.json with the following format:
[
{
"KeyPath": "test.automotive",
"DE": "Automobil",
"US": "...",
"CA": "...",
"GB": "...",
"ES": "...",
"FR": "...",
"IT": "...",
"MX": "..."
}
]
Editor file: Option 2: EXCEL_COPY_PASTE
EDITOR_FILE_EXCEL_COPY_PASTE.json with the following format:
IMPORTANT: Separators has to be tabs
test.automotive Automobil Automotive Automotive Automotive Automoción Automoción Automobile Automotive
The first column has to be the keypath or the replacement key The following columns has to be the translations (ORDER: DE, US, CA, GB, ES, MX, FR, IT)
Run script
Run the script with the following command: Navigate to the directory where your translations are and run the following command:
i18n-converter run
Things you might stumble over
- The translations may contain line breaks which could break the JSON format if not escaped => remove line breaks before converting
- Use market GB instead of UK in the EDITOR_FILE.json
- Use Key in EDITOR_FILE.json instead of e.g. ID/Text Key
Development
Make npm script available on your local machine
npm link