Demonstrates automated localization for a Ruby on Rails app that authors UI strings in config/locales YAML files, using Lingo.dev CLI and GitHub Actions.
Full walkthrough: lingo.dev/en/guides/ruby-on-rails-localization
config/locales/en.yml– source UI strings (English)config/locales/{es,fr,de}.yml– translated catalogs, generated by Lingo.devapp/controllers/application_controller.rb–switch_localearound_action that picks from URL param orAccept-Languageapp/views/home/index.html.erb– view demonstratingt()interpolation and pluralizationi18n.json– Lingo.dev CLI configuration (yaml-root-keybucket).github/workflows/translate.yml– GitHub Actions workflow
- Fork this repo
- Add
LINGODOTDEV_API_KEYto Settings > Secrets and variables > Actions - Push a change to
config/locales/en.yml - Translations appear automatically via commit to main
The Lingo.dev CLI reads config/locales/en.yml, identifies new or changed entries using a lockfile, translates the delta through a configured localization engine, and writes per-locale files (es.yml, fr.yml, de.yml) alongside the source. The locale root key (en: → es:), nested namespaces, %{name} interpolation, and plural categories (zero, one, other) are preserved – only translatable text changes. The GitHub Actions workflow runs this on every push to main.
Rails' built-in i18n API loads every YAML file under config/locales/ at boot. ApplicationController#switch_locale picks the request locale from a URL parameter or the Accept-Language header and wraps the action in I18n.with_locale, so views render translations with t() and l() helpers without leaking the locale across requests.
- Source:
en - Targets:
es,fr,de
bundle install
bin/rails serverOpen http://localhost:3000 – visit /en, /es, /fr, or /de to switch locale.
To translate locally:
npm install -g lingo.dev
lingo.dev run