I am building a single page ajax app with BackboneJS and a RoR 3.2 (upgraded from 3.1) backend. I use a client side I18n javascript translation library that holds its data in a JSON object. I am managing the translations in the backend with yml files and the default i18n gem. I have one translation asset per language, e.g English:
//FILE: <project_root>/app/assets/javascripts/translations/en.js.erb:
I18n || (I18n = {});
I18n.translations || (I18n.translations= {});
I18n.translations["en"] = <%= I18n.with_locale(:en) { I18n.t(".") }.to_json %>;
My translations are under config/locales/ and its sub-directories. I configured the load path as follows:
config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')]
So far so good, everything works fine, however, new translations added to the yaml files are not automatically available on the client after a page reload in dev mode. The new translations are only available if I restart the server and make a change in the corresponding translation asset (e.g. adding a blank line). This routine is pretty tedious...
- How can I explicitly tell the asset pipeline/sprockets to reprocess my translation assets every request? Or even better, is there a (simple) solution to monitor the yaml files and tell sprockets to reprocess the translation assets?
- Rails somehow does not auto-update the i18n translation hash when new translations are added to new or existing yaml files. I don't know why but this should normally work. Any clue?