vue-i18n-extract-keys
is built to work with your Vue.js projects using vue-i18n. When run vue-18n-extract-keys
, it extracts, from your Vue.js source code, any vue-i18n
key usages (ex. $t(''), $tc(''), ...) and generates corresponding assets locales files.
## NPM
npm install --save-dev @oreliain/vue-i18n-extract-keys
## or
## Yarn
yarn add -D @oreliain/vue-i18n-extract-keys
To extract keys executed the command :
npx vue-i18n-extract-keys
or create a script entry in your package.json
:
{
"scripts": {
"i18n:extract": "vue-i18n-extract-keys -o ./src/locales -l en fr -e -x"
}
}
The command takes the following options :
The locales to generate
Generate en.json
and fr.json
files in ./i18n/locales
npx vue-i18n-extrack-keys -l en fr
The source directories to parse for keys extracting
Extract keys from ./sources
and ./components
directories
npx vue-i18n-extrack-keys -s ./sources -s ./components
The target directory in which locale generated files will be stored. The directory must already exist
Extract keys to ./lang
directory
npx vue-i18n-extrack-keys -o ./lang
Create an index file in the output directory that export all your locales as a module.
npx vue-i18n-extrack-keys -l en fr -o ./lang --withIndexFile
will create a ./lang/index.js
file that contains :
module.exports = {
fr: require("./fr.json"),
en: require("./en.json")
};
Keep non existing translations keys in the result translation file.
By default, the command updates the output files on each run. Use this option to erase the output files instead of update it.
Set verbose mode
Dry run mode, do the parsing but do not write locales files
Show the differences between old and new locales files
Print the help message
Print the package version
I'm sure you'll find bugs and when you do it would be great if you'd could report them here.
The project is still in its early stages and in progress. There's no need for guidelines yet, so feel free to contribute or give feedback as you prefer.