- Home
- Skills
- Thibautbaissac
- Rails Ai Agents
- I18n Patterns
i18n-patterns_skill
269
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill thibautbaissac/rails_ai_agents --skill i18n-patterns- SKILL.md11.9 KB
Overview
This skill implements Rails I18n patterns to add and manage multi-language support across a Rails 8.1 application. It focuses on organized locale files, lazy lookups in views, locale switching, pluralization, and localized date/number/currency formatting. It also integrates i18n-tasks and test helpers to detect missing or unused translations.
How this skill works
It inspects and advises on locale file structure (models, views, components, mailers) and recommends nested keys that mirror view and model paths. It shows how to use t and l helpers in views, controllers, presenters, and components, and how to configure default/available locales and fallbacks. It also guides on configuring i18n-tasks and test hooks to fail on missing translations and to keep files normalized.
When to use it
- When adding translations for new UI text or models
- When implementing locale switching (URL or user preference)
- When localizing dates, times, numbers, or currencies
- When handling pluralization and complex locale rules
- When setting up translation health checks with i18n-tasks
Best practices
- Organize locale files by domain (models, views, components, mailers) and mirror view paths for lazy lookups
- Prefer lazy lookups in views (t('.key')) and use _html suffix for HTML content
- Keep pluralization keys (zero/one/other) and use count: for translations requiring counts
- Localize dates/numbers with I18n.l and Rails helpers; avoid hardcoded formats in views
- Run i18n-tasks in CI and include tests that raise on missing translations
Example use cases
- Add French and German translations for models, views, and components with consistent file layout
- Switch locale from URL scope and persist user preference for future requests
- Format currency per-locale and provide custom number/currency formats in locale files
- Write RSpec tests that fail when translations are missing or when locale files are unnormalized
- Use i18n-tasks to find and remove unused translations and to normalize locale YAML structure
FAQ
Configure I18n.exception_handler to raise in test environment and add i18n-tasks specs to ensure missing_keys is empty.
Where should translations live?
Place translations under config/locales and split by domain (models, views, components, mailers) using nested keys that reflect view and model paths.