Consider multilingual app with content-heavy static pages:
app/views/pages/faq.html.slim:
h2 '.question-1'
p '.answer-1'
/...
h2 = t '.question-20'
p = t '.answer-20'config/locales/en.yml
en:
pages:
faq:
question-1: What?
answer-1: That
#...config/locales/de.yml
en:
pages:
faq:
question-1: Was?
answer-1: Das
#......
app/views/pages/t.faq/en.yml
question-1: What?
answer-1: That
#...app/views/pages/t.faq/de.yml
question-1: Was?
answer-1: Das
#...- Easier to move files (with their translations)
- Intuitive
Add this line to your application's Gemfile:
gem 'folder_structure_reflecting_i18n_loader'
And then execute:
$ bundle
With Rails, update config/application.rb:
I18n::Railtie.reloader_paths.concat Dir.glob('app/views/**/*.yml')
I18n.backend = I18n::Backend::Chain.new(I18n.backend, FolderStructureReflectingI18nLoader::Loader.new) # Rails.root + app/views is default root for it
- Add rails example / specs
- Fork it ( http://github.com//folder_structure_reflecting_i18n_loader/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request