{"id":16184318,"url":"https://github.com/spittal/vue-i18n-extract","last_synced_at":"2025-04-12T21:33:52.909Z","repository":{"id":39587726,"uuid":"166724493","full_name":"Spittal/vue-i18n-extract","owner":"Spittal","description":"Manage vue-i18n localization with static analysis","archived":false,"fork":false,"pushed_at":"2023-07-19T14:13:04.000Z","size":210259,"stargazers_count":318,"open_issues_count":41,"forks_count":86,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-01-03T09:37:30.626Z","etag":null,"topics":["hacktoberfest","i18n","internationalization","internationalization-plugin","javascript","nodejs","vue","vue-i18n"],"latest_commit_sha":null,"homepage":"https://pixari.github.io/vue-i18n-extract/#what-is-it","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Spittal.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-01-21T00:25:40.000Z","updated_at":"2024-12-16T15:32:40.000Z","dependencies_parsed_at":"2024-01-08T08:57:09.775Z","dependency_job_id":null,"html_url":"https://github.com/Spittal/vue-i18n-extract","commit_stats":{"total_commits":367,"total_committers":35,"mean_commits":"10.485714285714286","dds":0.6130790190735695,"last_synced_commit":"382f5e5c6a18471681b30b340919fdcb897259e1"},"previous_names":["pixari/vue-i18n-extract"],"tags_count":55,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Spittal%2Fvue-i18n-extract","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Spittal%2Fvue-i18n-extract/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Spittal%2Fvue-i18n-extract/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Spittal%2Fvue-i18n-extract/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Spittal","download_url":"https://codeload.github.com/Spittal/vue-i18n-extract/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248636826,"owners_count":21137527,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","i18n","internationalization","internationalization-plugin","javascript","nodejs","vue","vue-i18n"],"created_at":"2024-10-10T07:09:49.399Z","updated_at":"2025-04-12T21:33:52.887Z","avatar_url":"https://github.com/Spittal.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n  \u003ca href=\"https://github.com/Spittal/vue-i18n-extract\"\u003e\u003cimg align=\"center\" width=\"70%\"src=\".github/img/vue-18n-extract-logo.png\" alt=\"vue-i18n-logo\"\u003e\u003c/a\u003e\n\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://www.npmjs.com/package/vue-i18n-extract\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/vue-i18n-extract.svg?style=flat-square\" alt=\"NPM Version\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/vue-i18n-extract\"\u003e\u003cimg src=\"https://img.shields.io/npm/dm/vue-i18n-extract.svg?style=flat-square\" alt=\"Downloads\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://snyk.io/test/github/Spittal/vue-i18n-extract?targetFile=package.json\"\u003e\u003cimg src=\"https://snyk.io/test/github/Spittal/vue-i18n-extract/badge.svg?targetFile=package.json\" alt=\"Known Vulnerabilities\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://codeclimate.com/github/Spittal/vue-i18n-extract/maintainability\"\u003e\u003cimg src=\"https://api.codeclimate.com/v1/badges/d21f341c33b2bfb6fe0e/maintainability\" alt=\"Maintainability\"\u003e\u003c/a\u003e\n  \u003cimg src=\"https://github.com/Spittal/vue-i18n-extract/workflows/Test/badge.svg?branch=master\" alt=\"Tests\"\u003e\n\u003c/p\u003e\n\n`vue-i18n-extract` is built to work with your Vue.js projects using the library [vue-i18n](https://kazupon.github.io/vue-i18n/). It runs static analysis on your Vue.js source code looking for any `vue-i18n` usage, in order to:\n\n- Report all **missing keys** in your language files.\n- Report all **unused keys** in your language files.\n- Optionally write every missing key into your language files.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg align=\"center\" width=\"80%\" src=\".github/img/vue-i18n-extract-screenshot.png\"\u003e\n\u003c/p\u003e\n\n## Content\n\n- [Usage](#usage)\n  - [From the command line](#from-the-command-line)\n  - [As part of a project](#as-part-of-a-project)\n  - [As part of a Node.js script](#as-part-of-a-node.js-script)\n- [Configuration](#configuration)\n  - [`vueFiles`](#vuefiles)\n  - [`languageFiles`](#languagefiles)\n  - [`output`](#output)\n  - [`add`](#add)\n  - [`remove`](#remove)\n  - [`ci`](#ci)\n  - [`separator`](#separator)\n  - [`exclude`](#exclude)\n  - [`noEmptyTranslation`](#noemptytranslation)\n  - [`missingtranslationstring`](#missingtranslationstring)\n- [Supported `vue-i18n` Formats](#supported-vue-i18n-formats)\n- [Why?](#why)\n- [Contribution](#contribution)\n- [License](#license)\n\n## Usage\n\n### From the command line\n\nRun from the command line:\n\n```sh\nnpx vue-i18n-extract report --vueFiles './path/to/source-files/**/*.?(js|vue)' --languageFiles './path/to/language-files/*.?(json|yml|yaml)'\n```\n\n### As part of a project\n\nInstall the package in your project:\n\n```sh\nnpm install --save-dev vue-i18n-extract\n```\n\nUse it via an npm script in your `package.json` file:\n\n```json\n{\n  \"scripts\": {\n    \"vue-i18n-extract\": \"vue-i18n-extract report --vueFiles './path/to/source-files/**/*.?(js|vue)' --languageFiles './path/to/language-files/*.?(json|yml|yaml|js)'\"\n  }\n}\n```\n\nFinally, run:\n\n```sh\nnpm run vue-i18n-extract\n```\n\nThis will print out a table of missing keys in your language files, as well as unused keys in your language files.\n\n### As part of a Node.js script\n\nInstall the package in your project:\n\n```sh\nnpm install --save-dev vue-i18n-extract\n```\n\nImport the module and use it like this:\n\n```js\nconst VueI18NExtract = require('vue-i18n-extract');\n\nconst report = VueI18NExtract.createI18NReport({\n  vueFiles: './path/to/vue-files/**/*.?(js|vue)',\n  languageFiles: './path/to/language-files/*.?(json|yml|yaml|js)',\n});\n```\n\n## Configuration\n\nYou can use the following configuration options via the vue-i18n-extract command line utility or a `vue-i18n-extract.config.js` configuration file.\n\nYou can generate a default configuration file using `npx vue-i18n-extract init` (it uses the following options: [`vue-i18n-extract.config.ts`](src/config-file/vue-i18n-extract.config.ts)). Once you have a configuration file, you can run `npx vue-i18n-extract`.\n\n### `vueFiles`\n\n* Name: `vueFiles`\n* CLI argument: `--vue-files`, `--vueFiles`\n* Required: Yes\n* Type: `string`\n* Description: A path to the directory of files from which you want to extract translation keys from. Can be a path to a file. Can include glob patterns (using [glob](https://www.npmjs.com/package/glob)). **Note for Windows users**: use forward slashes in paths.\n* Examples:\n  * `./path/to/source-files/**/*.?(js|vue)`\n  * `./tests/fixtures/**/*.?(vue|js)`\n\n### `languageFiles`\n\n* Name: `languageFiles`\n* CLI argument: `--language-files`, `--languageFiles`\n* Required: Yes\n* Type: `string`\n* Description: The language file(s) you want to compare your source file(s) to. It can be a path to a folder or a file. Can include glob patterns (using [glob](https://www.npmjs.com/package/glob)). **Note for Windows users**: use forward slashes in paths.\n* Examples:\n  * `./path/to/language-files/*.?(json|yml|yaml)`\n  * `./tests/fixtures/lang/**/*.json`\n\n### `output`\n\n* Name: `output`\n* CLI argument: `--output`\n* Required: No\n* Default: — (no report is saved by default)\n* Type: `string`\n* Description: Saves a report in JSON format containing all missing and unused translation keys at the given file path (the directory must exist for this to work).\n* Examples:\n  * `output.json`\n\n### `add`\n\n* Name: `add`\n* CLI argument: `--add`\n* Required: No\n* Default: `false`\n* Type: `boolean`\n* Description: Adds missing translation keys to your language files.\n\n### `remove`\n\n* Name: `remove`\n* CLI argument: `--remove`\n* Required: No\n* Default: `false`\n* Type: `boolean`\n* Description: Removes unused translation keys to your language files.\n\n### `ci`\n\n* Name: `ci`\n* CLI argument: `--ci`\n* Required: No\n* Default: `false`\n* Type: `boolean`\n* Description: Causes the process to exit with exit code 1 if at least one translation key is missing or unused (useful if it is part of a CI pipeline).\n\n### `separator`\n\n* Name: `separator`\n* CLI argument: `--separator`\n* Required: No\n* Default: `'.'`\n* Type: `string`\n* Description: Changes the default separator used in translation keys for nested translation paths.\n\n### `exclude`\n\n* Name: `exclude`\n* CLI argument: `--exclude`\n* Required: No\n* Default: `[]`\n* Type: `string` or array of `string`s\n* Description: Excludes the provided translation keys from the report. When using sub segments of dot notation paths (e.g. `company.meta` in `company.meta.motto`), the entire node of the object indicated by the sub segment will be excluded.\n* Examples:\n  * Configuration option: `exclude: ['translation_key_1', 'translation_key_2']`\n  * CLI argument: `--exclude translation_key_1 --exclude translation_key_2`\n\n### `detect`\n\n* Name: `detect`\n* CLI argument: `--detect`\n* Required: No\n* Default: `['missing', 'unused', 'dynamic']`\n* Type: `string` or array of `string`s\n* Description: Defines what do detect (and include) in the report.\n* Examples:\n  * Configuration option: `detect: ['missing', 'unused']`\n  * CLI argument: `--detect missing --detect unused`\n\n### `noEmptyTranslation`\n\n* Name: `noEmptyTranslation`\n* CLI argument: `--no-empty-translation`, `--noEmptyTranslation`\n* Required: No\n* Default: `''`\n* Type: `string`\n* Description: Generates a default translation for each translation key with no translation. The default translation will be the translation key itself.\n* Examples:\n  * `'*'`: Generate empty default translation for all locales.\n  * `'en'`: Generate empty default translation for locale `'en'`.\n  * `'en-US'`: Generate empty default translation for locale `'en-US'`.\n\n### `missingTranslationString`\n\n* Name: `missingTranslationString`\n* CLI argument: `--missing-translation-string`, `--missingTranslationString`\n* Required: No\n* Default: `''`\n* Type: `string` or `null`\n* Description: Text to use when missing translations are added to the translation files.\n* Examples:\n  * `'Translation missing'`: Use \"Translation missing\" as default key.\n  * `null`: Add the translation key to the file, but don't add a default translation. This will trigger `vue-i18n`'s the missingHandler.\n\n## Supported `vue-i18n` Formats\n\n- Static in template or script:\n```js\n// Single or double quote, and template literals\n$t('key.static') $t(\"key.static\") $t(`key.static`)\n\n// Without dollar sign\nt('key.static') t(\"key.static\") t(`key.static`)\n\n// $tc Support for use with plurals\n$tc('key.static', 0) $tc(\"key.static\", 1) $tc(`key.static`, 2)\n\n// Without dollar sign\ntc('key.static', 0) tc(\"key.static\", 1) tc(`key.static`, 2)\n```\n\n- i18n component:\n```html\n\u003ci18n path=\"key.component\"\u003e\u003c/i18n\u003e\n\u003ci18n-t keypath=\"key.component\"\u003e\u003c/i18n-t\u003e\n\u003cTranslate keypath=\"key.component\"\u003e\u003c/Translate\u003e\n```\n\n\u003e Note: As of right now there is no support for binding in a path like `:path=\"condition ? 'string1' : 'string2'\"` there is just support for strings as shown above.\n\n- i18n component in code:\n```js\nconst TranslationComponentInCode = h(Translation, {\n  keypath: 'Translation component in code.',\n  tag: 'p',\n});\n```\n\n- v-t directive with string literal:\n```html\n\u003cp v-t=\"'key.directive'\"\u003e\u003c/p\u003e\n\u003cp v-t.preserve=\"'key.directive'\"\u003e\u003c/p\u003e\n```\n\u003e Note: As of right now there is no object support to reference a path from component data.\n\n## Why?\n\nSetting up a Vue.js app with internationalization (i18n) support is easy nowadays: Once you have installed the plugin and injected into the Vue instance, you can just put `$t('Hello World')` inside Vue.js component templates to use the plugin.\nHowever, in our personal experience we found it very difficult to keep the language files and the `.vue` files in sync.\n\nThat's why we wrote `vue-i18n-extract`. We needed a way to analyze and compare our language files to our Vue.js source files, then report the result in a useful way.\n\n## Contribution\n\nPlease make sure to read the [Contributing Guide](.github/CONTRIBUTING.md) before making a pull request.\n\n## License\n\n[MIT](http://opensource.org/licenses/MIT)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspittal%2Fvue-i18n-extract","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspittal%2Fvue-i18n-extract","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspittal%2Fvue-i18n-extract/lists"}