← ClaudeAtlas

rails-i18nlisted

Use when adding or auditing internationalization (I18n) — locale file organization, lazy lookup, pluralization, number/date/currency formatting, per-request locale selection, fallbacks, translating validation errors and model/attribute names, and catching missing/unused keys with i18n-tasks. Triggers on "i18n", "internationalization", "translate", "locale", "pluralize", "missing translation", "l10n", "add a language".
mickzijdel/rails-toolkit · ★ 0 · AI & Automation · score 70
Install: claude install-skill mickzijdel/rails-toolkit
# Rails Internationalization (I18n) ## 1. Locale File Organization Nest keys by the same path the code lives at — `views.<controller>.<action>`, `<mailer>.<action>`, `activerecord.models`/`attributes`/`errors` — so a translator (or `grep`) can find a string from its call site alone. One file per locale, not per feature; features already nest under the top-level key. ```yaml # config/locales/en.yml en: boards: show: empty_state: "No cards yet. Add the first one." create: success: "Board created." activerecord: models: board: "Board" card: one: "Card" other: "Cards" attributes: card: title: "Title" due_on: "Due date" errors: models: card: attributes: title: blank: "can't be empty" ``` ```ruby # config/application.rb config.i18n.default_locale = :en config.i18n.available_locales = %i[ en fr de ja ] config.i18n.fallbacks = true # see Pattern 6 # config.i18n.load_path is auto-extended to config/locales/**/*.{rb,yml}; keep locale # files there rather than adding a custom load_path unless a gem needs one. ``` **Key Points:** - Split by locale (`en.yml`, `fr.yml`), not by feature (`boards.yml`, `cards.yml`) — a locale file is a translator's unit of work; a feature split forces them to hop files mid-review. - For large apps, `config/locales/en/boards.yml` (subdirectory, still keyed `en:` at the top) is fine — Rails loads th