{"id":13878197,"url":"https://github.com/conversation/i18n-hygiene","last_synced_at":"2025-07-16T14:31:41.763Z","repository":{"id":2599294,"uuid":"45884759","full_name":"conversation/i18n-hygiene","owner":"conversation","description":"A linter for translation data in ruby applications","archived":false,"fork":false,"pushed_at":"2022-02-23T22:45:45.000Z","size":165,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":12,"default_branch":"main","last_synced_at":"2024-11-20T14:06:49.708Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/conversation.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}},"created_at":"2015-11-10T03:24:38.000Z","updated_at":"2023-05-24T07:53:33.000Z","dependencies_parsed_at":"2022-08-06T12:30:38.759Z","dependency_job_id":null,"html_url":"https://github.com/conversation/i18n-hygiene","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conversation%2Fi18n-hygiene","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conversation%2Fi18n-hygiene/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conversation%2Fi18n-hygiene/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conversation%2Fi18n-hygiene/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/conversation","download_url":"https://codeload.github.com/conversation/i18n-hygiene/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226138849,"owners_count":17579496,"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":[],"created_at":"2024-08-06T08:01:42.471Z","updated_at":"2024-11-24T07:30:50.868Z","avatar_url":"https://github.com/conversation.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# i18n-hygiene [![Build Status](https://travis-ci.org/conversation/i18n-hygiene.svg?branch=master)](https://travis-ci.org/conversation/i18n-hygiene)\n\nProvides a configurable rake task to help maintain your translations.\n\nOver the lifetime of a project there tends to be a lot of churn in the translation files. Contexts and meanings will change, features will be added and removed. You'll find that soon enough, translations fall out of use, mistakes by developers or translators will creep in. The longer this goes on, the harder it is to keep them neat and tidy.\n\nThis tool is intended to be used as part of your continuous integration pipeline to keep your translations healthy and prevent issues from ever making it to production.\n\n## Usage\n\nInclude the gem in your gemfile and bundle:\n\n`gem 'i18n-hygiene'`\n\n## Integrating with rake\n\nCreate a rake task with the desired configuration. For example, this will create a rake task called `i18n:hygiene`:\n\n```ruby\nnamespace :i18n do\n  I18n::Hygiene::RakeTask.new do |config|\n    config.directories = [\"app\", \"lib\"]\n  end\nend\n\n```\n\nYou can then run the rake task with:\n```\nbundle exec rake i18n:hygiene\n```\n\nYou could also create separate rake tasks with different names and configurations, this may be useful if you are in the middle of rolling out a new locale:\n```ruby\nnamespace :i18n do\n  I18n::Hygiene::RakeTask.new(:hygiene_live) do |config|\n    config.locales = [:fr]\n  end\n\n  I18n::Hygiene::RakeTask.new(:hygiene_wip) do |config|\n    config.locales = [:es]\n  end\nend\n```\n\nWhich could be run like:\n\n```\nbundle exec rake i18n:hygiene_live\nbundle exec rake i18n:hygiene_wip\n```\n\n## Configuration\n\n| Configuration | Default | Description |\n|---|---|---|\n| `concurrency` | Number of CPU cores | How many threads to use for key usage check |\n| `directories` | All | Directories to search for key usage |\n| `exclude_files` | None | Excludes files from key usage check |\n| `exclude_keys` | None | Exclude individual keys  |\n| `exclude_scopes` | None | Exclude groups of keys |\n| `file_extensions` | `rb, erb, coffee, js, jsx` | Only look in files with these extensions for key usage |\n| `primary_locale` | `I18n.default_locale` | Translations from other locales are checked against this |\n| `locales` | `I18n.available_locales` | Translations from these are checked against primary |\n\nExample using all configuration options:\n\n```ruby\nI18n::Hygiene::RakeTask.new do |config|\n  config.concurrency = 16\n  config.directories = [\"app\", \"lib\"]\n  config.exclude_files = [\"README.md\"]\n  config.file_extensions = [\"rb\", \"jsx\"]\n  config.primary_locale = :en\n  config.locales = [:ja, :kr]\n  config.exclude_keys = [\n    \"my.dynamically.used.key\",\n    \"another.dynamically.used.key\"\n  ]\n  config.exclude_scopes = [\n    \"activerecord\",\n    \"countries\"\n  ]\nend\n\n```\n\n#### Without Rails\n\nUsing this gem without Rails is possible, but you'll need to load the translations manually first.\n\n```ruby\nnamespace :i18n do\n  require 'i18n'\n  require 'i18n/hygiene'\n\n  I18n.load_path = Dir[\"locales/*.yml\"]\n  I18n.backend.load_translations\n\n  I18n::Hygiene::RakeTask.new(:hygiene_live) do |config|\n    config.directories = [\"src\"]\n    config.locales = [:fr]\n  end\nend\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconversation%2Fi18n-hygiene","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fconversation%2Fi18n-hygiene","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconversation%2Fi18n-hygiene/lists"}