Install with yarn:
yarn add vue-i18n-extract --dev
Install with npm:
npm install --save-dev vue-i18n-extract
Vue I18n is a plugin for Vue.js which makes the internationalization and localization very easy.
However, managing and maintaining all the language files and the vue-i18n keys inside a project could be very demanding and vue-i18n-extract solves this problem.
Vue-i18n-extract performs a static analysis on a Vue.js project (which uses vue-i18n) and reports the following information:
Optionally you can decide to show the output in the console or in a json file.
The missing keys can also be automatically added to the given language files.
yarn run vue-i18n-extract report -v <vueFiles> -l --languageFiles <languageFiles>
or
npm run vue-i18n-extract report -v <vueFiles> -l --languageFiles <languageFiles>
Required options
-v, --vueFiles <vueFiles>,
The Vue.js file(s) you want to extract i18n strings from. It can be a path to a folder or to a file. It accepts glob patterns. (ex. *, ?, (pattern|pattern|pattern)
-l, --languageFiles <languageFiles>,
The language file(s) you want to compare your Vue.js file(s) to. It can be a path to a folder or to a file. It accepts glob patterns (ex. *, ?, (pattern|pattern|pattern)
Options
-o, --output <output>
Use if you want to create a json file out of your report. (ex. -o output.json)
-a, --add,
Use if you want to add missing keys into your json language files.,
-d, --dynamic,
Use if you want to ignore dynamic keys false-positive. Use it 2 times to get dynamic keys report.',
-ci,
The process will exit with exitCode=1 if at least one translation-key is missing (useful especially if it is part of a CI pipeline).',
Examples
npm run vue-i18n-extract report -v './demo/vue-files/**/*.?(js|vue)' -l './demo/lang/**/*.?(json|yaml|yml)'
Create an empty config file:
yarn run vue-i18n-extract init
Open the config file:
vue-i18n-extract.config.js
Edit the file and change the values:
module.exports = {
vueFilesPath: './', // The Vue.js file(s) you want to extract i18n strings from. It can be a path to a folder or to a file. It accepts glob patterns. (ex. *, ?, (pattern|pattern|pattern)
languageFilesPath: './', // The language file(s) you want to compare your Vue.js file(s) to. It can be a path to a folder or to a file. It accepts glob patterns (ex. *, ?, (pattern|pattern|pattern)
options: {
output: false, // false | string => Use if you want to create a json file out of your report. (ex. output.json)
add: false, // false | true => Use if you want to add missing keys into your json language files.
dynamic: false, // false | 'ignore' | 'report' => 'ignore' if you want to ignore dynamic keys false-positive. 'report' to get dynamic keys report.
}
};
Run the program:bash yarn run vue-i18n-extract use-config
We are very happy to get any kind of contribution to this project and we would like to make contributions to this project as easy and transparent as possible.
When contributing to this repository, please first discuss the changes you wish to make via issue, email, or any other method with the owners of this repository before making a change.
Please note we do have a code of conduct, please follow it in all of your interactions with the project.
You can use the GitHub repository page for the following contributions:
Pull requests are the best way to propose changes to the codebase. We actively welcome your pull requests.
Instructions for contributing:
master.In short, when you submit the code changes, your submissions are understood to be under the same MIT License that covers the project. Feel free to contact the maintainers if that's a concern.
We use GitHub issues to track public bugs. Report a bug by opening a new issue.
Great Bug Reports tend to have:
Jamie Spittal |
Raffaele Pizzari |
By contributing, you agree that your contributions will be licensed under its MIT License.