0

I'm trying to use I18n locales for a multisite application and wondering whether it's at all possible to load some extra translation locale files after the rails app has initialized?

I'm already using the excellent Globalize gem for ActiveRecord model translations, but I essentially want to be able to load the locales for a given site from it's own folder. I'm therefore trying to use something along the following lines in my site loader code:

I18n.load_path = File.join(site.path, 'locales')

Where the site.path variable relates to the current site's configuration & asset directory.

I don't want to rely on adding an i18n initializer to glob through the sites directory for locales for 2 reasons:

  1. I can't guarantee a different site won't use the same translatable string, and I don't want them overwriting each other.

  2. I don't want to have to restart the application each time a new site has been added.

If it helps, my logic to doing it this way allows for some sites to be multi language, and some not, and allows me to be lazy about whether a site is multi-language or not because if I can do the above successfully, I can use I18n.available_locales to determine whether or not to show the lanuage switcher in the admin app etc.

toomanyredirects
  • 1,972
  • 15
  • 23

0 Answers0