.claude/skills/i18n-patterns/SKILL.md
Implements internationalization with Rails I18n for multi-language support. Use when adding translations, managing locales, localizing dates/currencies, pluralization, or when user mentions i18n, translations, locales, or multi-language. WHEN NOT: English-only applications without localization needs, formatting handled by presenters, or date/number formatting in non-user-facing code.
npx skillsauth add ThibautBaissac/rails_ai_agents i18n-patternsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Rails I18n provides internationalization support:
# config/application.rb
config.i18n.default_locale = :en
config.i18n.available_locales = [:en, :fr, :de]
config.i18n.fallbacks = true
config/locales/
├── en.yml # English defaults
├── fr.yml # French defaults
├── models/
│ ├── en.yml # Model translations (EN)
│ └── fr.yml # Model translations (FR)
├── views/
│ ├── en.yml # View translations (EN)
│ └── fr.yml # View translations (FR)
├── mailers/
│ ├── en.yml # Mailer translations (EN)
│ └── fr.yml # Mailer translations (FR)
└── components/
├── en.yml # Component translations (EN)
└── fr.yml # Component translations (FR)
Organize locale files by domain: models/, views/, mailers/, components/.
activerecord.models, activerecord.attributes, activerecord.errorsevents.index.title)common.actions, common.messages, common.date.formatscomponents.<component_name>.<key>See locale-files.md for complete YAML examples for models, views, shared keys, and components.
t(".title") resolves to "events.index.title"_html suffix for strings containing HTML markupI18n.l (localize) for dates, times, and numbers — not I18n.tI18n.t with full key path in models, services, and presenterst(".greeting", name: user.name)<h1><%= t(".title") %></h1>
<%= link_to t(".new_event"), new_event_path %>
<p><%= t(".welcome", name: current_user.name) %></p>
<p><%= t(".intro_html", link: link_to("here", help_path)) %></p>
redirect_to @event, notice: t(".success")
I18n.t("activerecord.attributes.event/statuses.#{status}")
I18n.l(event_date, format: :long)
See usage-patterns.md for full examples including presenters, components, date/currency formatting, and pluralization.
# config/routes.rb
Rails.application.routes.draw do
scope "(:locale)", locale: /en|fr|de/ do
resources :events
end
end
# app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
around_action :switch_locale
private
def switch_locale(&action)
locale = params[:locale] || I18n.default_locale
I18n.with_locale(locale, &action)
end
def default_url_options
{ locale: I18n.locale }
end
end
class ApplicationController < ActionController::Base
around_action :switch_locale
private
def switch_locale(&action)
locale = current_user&.locale || extract_locale_from_header || I18n.default_locale
I18n.with_locale(locale, &action)
end
def extract_locale_from_header
request.env['HTTP_ACCEPT_LANGUAGE']&.scan(/^[a-z]{2}/)&.first
end
end
spec/rails_helper.rbi18n-tasks gem to detect missing and unused keysSee testing.md for complete spec examples and i18n-tasks configuration.
# Use nested structure matching view paths
en:
events:
index:
title: Events
show:
title: Event Details
# Use interpolation for dynamic content
en:
greeting: "Hello, %{name}!"
# Use _html suffix for HTML content
en:
intro_html: "Welcome to <strong>our app</strong>"
# Don't use flat keys
en:
events_index_title: Events # BAD
# Don't hardcode in views
<h1>Events</h1> # BAD - use t(".title")
# Don't concatenate translations
t("hello") + " " + t("world") # BAD
development
Creates Turbo Streams, Turbo Frames, and morphing patterns for real-time UI updates. Use when adding real-time updates, partial page rendering, form submissions, or broadcasting. WHEN NOT: For Stimulus JavaScript controllers (see stimulus-patterns skill). For general view conventions (see rules/views.md).
testing
Writes Minitest tests with fixtures following 37signals conventions. Uses Minitest (not RSpec) and fixtures (not factories). Use when writing tests, adding test coverage, or creating fixtures. WHEN NOT: For RSpec or FactoryBot patterns (this project uses Minitest + fixtures exclusively). For test configuration/CI setup (see project docs).
tools
Builds focused, single-purpose Stimulus controllers for progressive enhancement. Use when adding JavaScript behavior, UI interactions, form enhancements, or building reusable client-side components. WHEN NOT: For Turbo Stream/Frame patterns (see turbo-patterns skill). For server-side view logic (see rules/views.md).
testing
Implements the state-as-records-not-booleans pattern for rich state tracking. Use when modeling state changes, replacing boolean flags with record-based state, or when user mentions state records, closures, publications, or toggling state. WHEN NOT: Technical flags like cached/processed (use booleans), concern extraction (use concern-patterns), general model work (use model-patterns).