I18n Extractor Agent
Finds hardcoded strings in views, controllers, and models, then extracts them to locale YAML files. Prepare your Rails app for internationalization systematically.
The "We'll Translate It Later" Problem
Hardcoded strings seem harmless until you need to support multiple languages:
- "We only need English for now" — then you close a deal in France
- "It's just a button label" — times 500 buttons across the app
- "Find and replace will work" — until you break the app with a typo
- "The translations are scattered everywhere" — no consistent key structure
The result? A massive, error-prone project to extract strings when you finally need i18n. Or worse, maintaining two separate codebases.
How the Agent Works
Hardcoded String Scan
Finds all user-facing text that needs extraction.
- → Scans views, partials, and helpers for hardcoded text
- → Identifies flash messages in controllers
- → Finds validation error messages in models
Key Structure Design
Creates organized, consistent translation keys.
-
→
Follows Rails i18n conventions:
en.users.show.welcome -
→
Uses absolute paths only (no
t(".key")relative keys) - → Groups by feature/controller, not by type
Locale File Creation
Generates properly formatted YAML locale files.
- → Creates hierarchical YAML with proper indentation
- → Uses double quotes for all values (YAML best practice)
-
→
Handles interpolation:
%{name}for dynamic values
Code Replacement
Replaces hardcoded strings with t() helper calls.
-
→
Replaces strings in ERB templates:
<%= t("users.show.title") %> -
→
Replaces strings in Ruby code:
I18n.t("general.back") - → Preserves string behavior with correct interpolation
Verification
Ensures the app still renders correctly after extraction.
- → Verifies all pages render without missing translation errors
- → Runs test suite to catch broken interpolation
- → PR shows before/after string counts.
What Gets Extracted
Extracted
- • View text and labels
- • Button and link text
- • Flash messages (notice, alert)
- • Validation error messages
- • Email subjects and content
- • Form placeholders
NOT Extracted
- • Log messages (developer-facing)
- • Exception messages (technical)
- • Test assertions
- • Code comments
- • Database seed data
- • Configuration values
Safety Guarantees
Behavior Preserved
Extracted strings render exactly as before. Users notice nothing.
Absolute Keys Only
Uses full paths like t("users.show.title"), never t(".title").
Valid YAML
All locale files pass YAML lint. No syntax errors.
Test Validation
Full test suite runs after extraction to catch issues.
Interpolation Handled
Dynamic values converted to %{variable} interpolation.
Incremental PRs
Can extract by feature/controller for easier review.
What This Is NOT
- ✗ Not translation. Extracts strings to locale files. Translation is separate.
- ✗ Not find-and-replace. Understands context and creates proper key hierarchies.
- ✗ Not extracting everything. Only user-facing strings, not technical messages.
- ✗ Not using relative keys. Absolute paths only for maintainability.
Typical Results
Ready to Internationalize Your App?
Start with a $1,500 audit. Get a report of all hardcoded strings and a plan for systematic extraction.