An AI-powered i18n command and its Demo Rails application.
ANTHROPIC_API_KEY is required to use the AI.
export ANTHROPIC_API_KEY="YOUR_API_KEY"- Pass the file you want to convert with
bin/i18n suggest $fileto output a JSON file for code conversion- AI detects Japanese parts from
$fileand rewrites them tot(key)- The AI will come up with appropriate
keynames
- The AI will come up with appropriate
- JSON file for code conversion
file: Original file namecontent: Converted file contentja: Content to be written toconfig/locales/ja.ymlwith flattened keys
- AI detects Japanese parts from
- Compare the current content with the converted file content using
bin/i18n diff $file- If something is broken or you want to change key names, use
bin/i18n open $fileto open and edit the JSON file for code conversion
- If something is broken or you want to change key names, use
- Apply the JSON file for code conversion using
bin/i18n apply $file- This will modify
$fileandconfig/locales/ja.yml
- This will modify
- Use
bin/i18n translate $localeto translateconfig/locales/ja.ymland generateconfig/locales/${locale}.yml
$ brew install jq
$ bundle add i18n-tasks -g developmentfor file in i18n i18n-suggest i18n-translate; do
curl -L -o "bin/${file}" "https://raw.githubusercontent.com/en30/ai18n/refs/heads/main/bin/${file}"
chmod +x "bin/${file}"
doneEdit as appropriate to suit your project.