rails-i18nlisted
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