{"id":22080652,"url":"https://github.com/basvdijk/i18n-cleaner","last_synced_at":"2026-05-09T01:03:32.139Z","repository":{"id":57748914,"uuid":"524059630","full_name":"basvdijk/i18n-cleaner","owner":"basvdijk","description":"Checks for missing translations in your source code, and unused translations in your locale JSON files. ","archived":false,"fork":false,"pushed_at":"2022-08-12T12:09:41.000Z","size":206,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-13T10:37:59.063Z","etag":null,"topics":["angular","i18n","internationalization","ngx-translate","vue","vue-i18n"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/basvdijk.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-08-12T11:17:45.000Z","updated_at":"2022-08-14T17:32:48.000Z","dependencies_parsed_at":"2022-08-25T18:11:32.191Z","dependency_job_id":null,"html_url":"https://github.com/basvdijk/i18n-cleaner","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basvdijk%2Fi18n-cleaner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basvdijk%2Fi18n-cleaner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basvdijk%2Fi18n-cleaner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basvdijk%2Fi18n-cleaner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/basvdijk","download_url":"https://codeload.github.com/basvdijk/i18n-cleaner/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245168808,"owners_count":20571799,"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":["angular","i18n","internationalization","ngx-translate","vue","vue-i18n"],"created_at":"2024-11-30T23:16:16.425Z","updated_at":"2026-05-09T01:03:27.118Z","avatar_url":"https://github.com/basvdijk.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# i18n Cleaner\n\nChecks for missing translations in your source code, and unused translations in your locale JSON files.\n\nIf your website or application supports multiple languages you probably use a library to manage these translations like: \n- [VUE I18n](https://vue-i18n.intlify.dev/) for VUE\n- [ngx-translate](https://github.com/ngx-translate/core) for Angular\n\nOver time the locale JSON files contain keys which are not used anymore and the source contains keys which are missing in the translation files.\n\nThis project helps to detect:\n- If a translation key used in the source code is missing \n- If a translation key in the JSON file is not used in the code\n\nAnd reports them in your console.\n\n## Acknowlegements\nSpecial thanks to [@christiaanvaneijk](https://github.com/christiaanvaneijk) for reviewing my code!\n\n## Todo\nThere is still some work I might implement some day:\n- Check for differences between the JSON locale files.\n\n## Example projects\nThe `test` folder contains example projects where some translations are missing. \n\nCurrently there are two example projects:\n- VUE `npm run example:vue`\n- Angular `npm run example:angular`\n\n## Example output\n![image](https://user-images.githubusercontent.com/644550/184345809-b2ae7398-501a-40c8-90ef-e45ceb660d21.png)\n\n\n## Running the project\nIn order to run i18n-cleaner you have to create a config file e.g. `i18n-cleaner.conf.json`\n\nThis project uses a JSON file as its configuration. Here you define your source folder, filters and locale files. In the test folder there is an example config file `i18n-cleaner.valid.conf.json`\n\nUse `node src/index.js i18n-cleaner.conf.json` to run the i18n-cleaner\n\nOr run one of the example projects:\n\n- VUE `npm run example:vue` which outputs:\n\n![image](https://user-images.githubusercontent.com/644550/184345833-58b5f47b-3720-4acb-8299-0c522acb1970.png)\n\n- Angular `npm run example:angular` which outputs:\n\n![image](https://user-images.githubusercontent.com/644550/184345868-ab51c319-b73e-4a05-8080-fbd21d6349af.png)\n\n\n## Configuration file options\n\nExample config:\n```json\n{\n  \"extensions\": [\"vue\", \"ts\"],\n  \"i18nFilters\": [\n    \"(\\\\ |\\\"|\\\\()t\\\\([\\\"'](.*)[\\\"'](.*)\\\\)\",\n    \"pageTitleTranslationKey:(.*)[\\\"']\"\n  ],\n  \"locales\": [\n    \"./i18n/en.json\", \n    \"./i18n/nl.json\", \n    \"./i18n/de.json\"\n  ],\n  \"localesFormat\": \"json\",\n  \"srcFolder\": \"./src\"\n}\n```\n\n### extensions\n*Array* with the file extensions that should be scanned\n\n```json\n\"extensions\": [\"vue\", \"ts\"]\n```\n\n### i18nFilters\n*Array* with **JSON escaped** regex strings to filter the source with.\n\nYou can use for example [this JSON escaper](https://www.freeformatter.com/json-escape.html) to escape your regexes.\n\nThis example is beging used for to filter the example `.vue` files in the `test` folder. I use [RegEx 101](https://regex101.com/) to compose the correct regexes.\n\n```json\n\"i18nFilters\": [\n    \"(\\\\ |\\\"|\\\\()t\\\\([\\\"'](.*)[\\\"'](.*)\\\\)\",\n    \"pageTitleTranslationKey:(.*)\\\\\\\"\"\n]\n```\n\nPlease take in mind that some regexes filter more than you wish. I first thought that filtering `t(` was enough. Till I noticed that `split(` was included as well. \n\nThe same goes with single and double quotes.\n\n### locales\n*Array* with path(s) to locale files. The first defined locale is considered to be the reference/main locale.\n```json\n  \"locales\": [\n    \"./i18n/en.json\", \n    \"./i18n/nl.json\", \n    \"./i18n/de.json\"\n  ],\n```\n\n### localesFormat\n*String* with locales format. Currently only `json` is supported\n```json\n  \"localesFormat\": \"json\",\n```\n\n### srcFolder\n*String* with path pointing to the source code folder\n```json\n  \"srcFolder\": \"./src\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasvdijk%2Fi18n-cleaner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbasvdijk%2Fi18n-cleaner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasvdijk%2Fi18n-cleaner/lists"}