{"id":15015918,"url":"https://github.com/mainmatter/ember-intl-analyzer","last_synced_at":"2025-04-05T01:04:56.720Z","repository":{"id":34641362,"uuid":"181456996","full_name":"mainmatter/ember-intl-analyzer","owner":"mainmatter","description":"Find missing or unused translations in your Ember.js projects","archived":false,"fork":false,"pushed_at":"2025-04-01T21:49:46.000Z","size":2744,"stargazers_count":49,"open_issues_count":24,"forks_count":16,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-01T22:35:53.854Z","etag":null,"topics":["ember-intl","emberjs","i18n","translations"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/mainmatter.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-15T09:41:39.000Z","updated_at":"2025-04-01T21:49:24.000Z","dependencies_parsed_at":"2023-09-28T21:02:54.468Z","dependency_job_id":"108ceecf-b6fe-4ad1-bf6c-6fd16776f87d","html_url":"https://github.com/mainmatter/ember-intl-analyzer","commit_stats":{"total_commits":603,"total_committers":23,"mean_commits":"26.217391304347824","dds":0.5621890547263682,"last_synced_commit":"c5153180e7fc80083050a693c7876776b57e1ba5"},"previous_names":["simplabs/ember-intl-analyzer"],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mainmatter%2Fember-intl-analyzer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mainmatter%2Fember-intl-analyzer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mainmatter%2Fember-intl-analyzer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mainmatter%2Fember-intl-analyzer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mainmatter","download_url":"https://codeload.github.com/mainmatter/ember-intl-analyzer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246724608,"owners_count":20823542,"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":["ember-intl","emberjs","i18n","translations"],"created_at":"2024-09-24T19:48:08.984Z","updated_at":"2025-04-05T01:04:56.704Z","avatar_url":"https://github.com/mainmatter.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ember-intl-analyzer\n\nFind unused translations in your Ember.js projects\n\n\u003e [!NOTE]\n\u003e ember-intl-analyzer was written and is maintained by\n\u003e [Mainmatter](https://mainmatter.com) and contributors.\n\u003e We offer consulting, training, and team augmentation for Ember.js – check out\n\u003e our [website](https://mainmatter.com/ember-consulting/) to learn more!\n\n## Usage\n\n```bash\nnpx ember-intl-analyzer\n```\n\n## Configuration\n\nember-intl-analyzer can be configured by creating a `config/ember-intl-analyzer.js`\nfile in your app:\n\n```js\nexport default {\n  whitelist: [/^countries\\./, /^currency\\./, /^validations\\.errors\\./, /^[^.]+\\.warnings\\.[^.]+$/],\n};\n```\n\n### `whitelist`\n\nIf you use dynamic translations keys like this:\n\n```js\nthis.intl.t(`countries.${code}`);\n```\n\nthen ember-intl-analyzer can not easily understand what translation keys are\nbeing used here. In that case it will ignore the dynamic translation key and\nshow the corresponding translations as unused.\n\nTo prevent that from happening you can configure a `whitelist`, which accepts an\narray of regular expressions that will be checked when looking for unused\ntranslations.\n\n### `errorOnUnusedWhitelistEntries`\n\nWhen using a whitelist to ignore dynamic translation keys, it can be easy to forget\nto clean up the whitelist when an entry is not used anymore. You can opt-in to make\nthis analyzer error when this occurs, by setting the `errorOnUnusedWhitelistEntries`\nflag in the configuration file:\n\n```js\nexport default {\n  errorOnUnusedWhitelistEntries: true,\n};\n```\n\n### `analyzeConcatExpression`\n\nIf your template contains translations like this:\n\n```hbs\n{{t (concat 'actions.' (if @isEditing 'save' 'publish'))}}\n```\n\nthen ember-intl-analyzer does not detect that `actions.save` and `actions.publish`\nare in fact used translations, so they can be incorrectly flagged as missing or\nunused. As the `concat` helper can make it harder to read, it's encouraged to\nrewrite it to for example:\n\n```hbs\n{{if @isEditing (t 'actions.save') (t 'actions.publish')}}\n```\n\nHowever, if your application relies heavily on this `concat` helper, then rewriting\nmay not be the best option for you. In that case, you can opt-in to analyze `concat`\nexpressions too by setting the `analyzeConcatExpression` flag in the configuration file:\n\n```js\nexport default {\n  analyzeConcatExpression: true,\n};\n```\n\n### `externalPaths`\n\nIf your application uses translations provided by (external) addons, then those\ntranslations will show up as missing by default. In order to include such translations,\nyou can define `externalPaths` in the configuration file as follows:\n\n```js\nexport default {\n  externalPaths: ['my-addon'],\n};\n```\n\nThis example will try to find translation files in `node_modules/my-addon/translations`.\nPatterns supported by [`globby`](https://www.npmjs.com/package/globby) are also\npossible here, e.g. this:\n\n```js\nexternalPaths: ['@*/*'];\n```\n\nwill look up translations in scoped addons like `node_modules/@company/scoped-addon/translations`.\n\n### `translationFiles`\n\nBy default, this addon will try to find missing and unused translations in any YAML or\nJSON file within the `translations` folders of your application (`['**/*.json', '**/*.yaml', '**/*.yml']`).\nHowever, if you would like to only analyze a subset of translation files, you can override\n`translationFiles` in the configuration file as follows:\n\n```js\nexport default {\n  translationFiles: ['**/en.yaml'],\n};\n```\n\nThis example will try to find all `en.yaml` files in the different `translations`\nfolders, but any patterns supported by [`globby`](https://www.npmjs.com/package/globby) are also\npossible here.\n\n### `wrapTranslationsWithNamespace`\n\nIf you are nesting your translations with `ember-intl`s [`wrapTranslationsWithNamespace`](https://ember-intl.github.io/ember-intl/docs/advanced/configuration#wraptranslationswithnamespace) you will need to set the corresponding property within your `ember-intl-analyzer` config file.\n\n```js\nexport default {\n  wrapTranslationsWithNamespace: true,\n};\n```\n\n### `babelParserPlugins` `extensions`\n\nIf your application uses doesn't parse correctly because it requires a specific babel plugin you can specifiy them in the config file under the key `babelParserPlugins` a list on plugins can be found [here](https://babeljs.io/docs/en/babel-parser#plugins).\n\nFor example if you would like typescript support you can specify the `typescript` plugin, although please note if the plugin introduces a new file extension you will also need to specifiy that in the `extensions` property. See the examples below.\n\nTypescript example\n\n```js\nexport default {\n  babelParserPlugins: ['typescript'],\n  extensions: ['.ts'],\n};\n```\n\nJsx example\n\n```js\nexport default {\n  babelParserPlugins: ['jsx'],\n  extensions: ['.jsx'],\n};\n```\n\nGts example\n\n```js\nexport default {\n  babelParserPlugins: ['typescript'],\n  extensions: ['.gts'],\n};\n```\n\n### `--fix`\n\nIf your application has a lot of unused translations you can run the command with\nthe `--fix` to remove them. Remember to double check your translations as dynamic\ntranslations need to be whitelisted or they will be removed!\n\n### `Custom t helpers`\n\nBy default this package will only check templates for `ember-intl`'s `t` helper, but\nin some cases you may want to create a custom wrapping helper e.g. `{{t-error 'error.key' error}}`\nthis helper could manage generic error situation but also accept a custom error key.\nIf your app uses custom `t` helpers you can register them in you config under the helpers key.\n\n**Note: This requires the translation key to be the first parameter of the helper**\n\n```js\nexport default {\n  helpers: ['t-error'],\n};\n```\n\n## Caveats\n\nThere are a number of things that we do not support yet. Have a look at the\n[Issues](https://github.com/Mainmatter/ember-intl-analyzer/issues) before using\nthis project.\n\n## Related\n\n- [ember-intl](https://github.com/ember-intl/ember-intl) – Internationalization\n  addon for Ember.js\n\n## License\n\nThis projects is developed by and \u0026copy; [Mainmatter GmbH](http://mainmatter.com)\nand contributors. It is released under the [MIT License](LICENSE.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmainmatter%2Fember-intl-analyzer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmainmatter%2Fember-intl-analyzer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmainmatter%2Fember-intl-analyzer/lists"}