1.1.0 • Published 3 years ago
@borerteam/vite-plugin-missing-locales v1.1.0
@borerteam/vite-plugin-missing-locales
A Vite plugin that helps you find missed keys in your localization files.
Installation
npm install @borerteam/vite-plugin-missing-localesyarn add @borerteam/vite-plugin-missing-localespnpm add @borerteam/vite-plugin-missing-localesUsage
Add the plugin to your vite.config.js file:
import missingLocales from '@borerteam/vite-plugin-missing-locales';
export default {
// ...other options
plugins: [
// ...other plugins
// `command === 'serve'` for run plugin only in dev mode
command === 'serve' && missingLocales({
path: './src/locales', // optional, default is './src/locales'
wait: 500, // optional, default is 500 (milliseconds),
defaultNamespace: 'translation', // optional, default is 'translation'
}),
],
};Options
path(optional, default is'./src/locales'): the path to thesrc/localesdirectory.wait(optional, default is500): the number of milliseconds to wait before running the plugin.defaultNamespace(optional, default is'translation'): the default namespace to use when the namespace is not specified.
Output
The plugin will output a list of strings in the following format:
[vite-plugin-missing-locales] ${locale}/${namespace}.json -> '${key}'For example:
[vite-plugin-missing-locales] en/common.json -> 'hello'
[vite-plugin-missing-locales] ua/auth.json -> 'login'
[vite-plugin-missing-locales] ru/error.json -> 'help'This indicates that the 'hello' key is missing from the en/common.json file.