In a Rails 4 multidomain app, I would need a set of locale files for 4 languages for each domain (3 domains total).
Some of the translations overlap between the domains but some of them are very specific, so I am thinking about a structure that would go somewhat like this:
config/locales/en.yml ..fr.yml ..de.yml ..it.yml #is picked up by all domains
config/locales/domain1/en.yml ..fr.yml ..de.yml ..it.yml #is picked up by domain 1
config/locales/domain2/en.yml ..fr.yml ..de.yml ..it.yml #is picked up by domain 2
config/locales/domain3/en.yml ..fr.yml ..de.yml ..it.yml #is picked up by domain 3
Is this possible in Rails 4? And if so what would be the best way to go about this setup?
in config/application
you would have:
some_domain = Rails.root.basename.to_s # this will give us "myapp.com" if the app is in "/var/www/myapp.com"
config.i18n.load_path += Dir[Rails.root.join('config', 'locales', some_domain, '*.{rb,yml}').to_s]
this will load only the required files and should overwrite any duplicate keys with the later data, but i haven't tested that bit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With