Hi everyone. I use rails 3.0.4, and Babilu a plugin to use rails-i18n in javascript code (see http://tore.darell.no/posts/introducing_babilu_rai...) Babilu generates a javascript file that contains all the translations i can just call Babilu.generate to generate this file from i18n rails translations The thing is, it works very well on developpement mode, because Babilu generate the locales.js file at each request. On production mode, babilu just generate his locales.js file at the initialisation of the plugin. But, since rails3, it seems to be broken : now the Babilu script can just mirror the native translations, but not the translations i added myself. In rails 2.3.8 it was working with a I18n.reload! to force translations loading, but it doesn't seems to work now. (see https://github.com/lou/babilu/commit/71aef7470cdab... ) I can figure out when does my "custom" translations (that i put in config/locales/en.yml) are loaded in i18n, and where can i put an initializer script, at the start of the production server, to have working i18n translations. I tried to put code in config/initializer, in application.rb, it doesn't work. I found nothing on rails guides. I've got no error to show you, because it's just translation missing: en.controller.blabla in my locales.js file If anyone can help me it would be very nice (it will help me to not rebuild static files at each request) you can find my babilu fork at https://github.com/piercus/babilu Thanks a lot Pierre
on 2011-02-25 16:30
on 2011-03-03 21:36
Pierre,
until babilu is updated to work with Rails3, this following workaround
works fine for me.
In application.rb, add this inside the Application class:
config.after_initialize do
Babilu.generate
end
This generates locales.js just after Rails has done initializing.
Ingmar
on 2011-04-06 09:31
Hi At first glance Babilu seemed to be exactly what I was looking for: no need to have extra translation logic for Javascript : just use rails. However it is unclear what exactly it does. I see that it generates a file called locales.js, in theory containing what is in your translation files in rails, however I see a lot of extraneous stuff in that file, like a list of countries apparently from factory_girl. How to stop it doing this? Does babilu load all translations whenever you call generate ? When does it use the default (as in default locale in locales.js)? I see that there is a fork to etagwerker-babilu which purports to optimise the creation of the file. But it doesn't say how. It is early days in the project but will end up with a lot of big translation files in many languages. It would be better to have babilu just load 1 translation file per language for the javascript or only translation files when a new language is selected by the user. Are there any options for such things in babilu? Is there another option for i18n in javascript in combo with rails? Regards dukha
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.