talira

i18n-tasks

Manage translation and localization with static analysis, for Ruby i18n

open sourceMITself-hostablefree

i18n-tasks finds missing and unused translations in Ruby projects that use the i18n gem, the default in Ruby on Rails. It scans code statically for key usages such as I18n.t('some.key') (an AST scanner for Ruby and ERB, optionally Prism-based, and a regexp scanner for other files), compares them with the YAML or JSON locale files, and checks interpolation variables and normalization. Its commands add missing keys, translate them with Google Translate, DeepL, Yandex, OpenAI or watsonx, remove unused keys, normalize, move and rename keys, and export to CSV, and it ships RSpec and Minitest templates that run the checks in CI.

Problems it solves

  • a missing translation only shows up when a user opens that page in French
  • find translation keys in our locale files that the code no longer uses
  • fail CI when a Rails view uses a translation key that isn't in every locale
  • fill in missing translations with machine translation as a first draft for translators
  • keep YAML locale files sorted and consistently formatted
  • rename or move a group of translation keys across all locale files at once
  • check that interpolation variables like %{name} match across languages
  • where in the code is this translation key used?
  • export translations to CSV for translators and import their edits back
  • remove keys from other languages that no longer exist in the base language
  • add placeholder entries for every key missing from a new locale

Features

  • health check: missing and unused keys, interpolation consistency, normalization
  • find: where keys are used
  • add-missing with placeholder values
  • translate-missing with Google Translate, DeepL, Yandex, OpenAI or watsonx
  • unused and remove-unused, with optional dynamic key inference
  • prune keys absent from the base locale
  • normalize and move keys into files by pattern routers
  • mv to rename, move and merge keys; rm to delete
  • composable tasks that pipe YAML or JSON between commands
  • AST scanner for Ruby and ERB, Prism-based scanner, regexp scanner for other files
View 3 more
  • YAML and JSON locale files, custom data adapters
  • CSV import and export, interactive console, custom tasks
  • RSpec and Minitest templates for CI

Limitations

  • Doesn't detect dynamic translation keys by default: keys built with interpolation need hints or the non-strict mode1
  • Doesn't detect keys used through I18n.localize: they depend on the object's type, so they need i18n-tasks-use hints1

Capabilities

Has an APIplan not known
Has a command line toolplan not known
Takes pluginsplan not known