locale-extractor
Tools to extract hardcoded text from Liquid files and replace them with translation keys.
When & Why to Use This Skill
The Locale Extractor is a specialized Claude skill designed to streamline the internationalization (i18n) process for Liquid-based projects. It automatically scans Liquid files to identify hardcoded strings, replaces them with dynamic translation keys using the `t` filter, and generates structured locale JSON files, significantly reducing manual effort and improving code maintainability.
Use Cases
- Shopify Theme Localization: Efficiently convert hardcoded Shopify themes into multi-language supported stores by automating the extraction of UI text into locale files.
- Legacy Code Refactoring: Modernize existing Liquid templates by replacing static text with translation filters, ensuring the codebase follows internationalization best practices.
- Automated Locale Generation: Speed up the development workflow by automatically creating nested JSON structures for translations while editing Liquid sections and snippets.
| name | Locale Extractor |
|---|---|
| version | 1.0.0 |
| description | Tools to extract hardcoded text from Liquid files and replace them with translation keys. |
Capabilities
Helps developers internationalize their themes by finding hardcoded strings and moving them to a locale JSON structure.
Tools Usage Guide
1. extract_locales
Scans Liquid content for hardcoded text inside HTML tags and proposes replacements.
- Param
liquid_content: The raw liquid code. - Param
section_name: The name of the section (used for key namespacing). - Returns:
modified_liquid: The code with{{ 'key' | t }}replacements.new_locales: A JSON object with the extracted keys and values.
Example
Input:
<h1>Hello World</h1>
<p>Welcome to our store</p>
Output:
{
"modified_liquid": "<h1>{{ 'sections.header.hello_world' | t }}</h1>\n<p>{{ 'sections.header.welcome' | t }}</p>",
"new_locales": {
"sections": {
"header": {
"hello_world": "Hello World",
"welcome": "Welcome to our store"
}
}
}
}