Shortly: asset-pipeline + i18n
Some additional words: you would like to internationalize your javascript/css files the same way you do in the rest of application. For example you would like to write something like:
app/assets/file.js.erb
alert(<%= I18n.t('javascript.key.name') %>)
That works OK in development mode but with asset pipeline you have only one precompiled and (cached) application.js file translated with the default language. What you would need is a collection of language specific application.js files, like application-en.js, application-it.js, etc. This gem is exactly for that!
In your Gemfile
group :assets do gem 'asset_pipeline_i18n' end
In your application.rb
config.assets.localized_precompile = ['application-it.js', 'application-fr.js', 'application-de.js', 'application-en.js']
then
rake assets:precompile i18n:assets:precompile
Of course you also have to use something like:
javascript_include_tag "application-#{I18n.locale}"
The idea is to use the same version number of the Rails version the gem is compatible with. So asset_pipeline_i18n version 3.2.5 is for Rails 3.2.5 and so on. If the gem is broken and we have to release a fix, then we will use a forth levelnumber, like 3.2.5.1 To keep things easy, the dependency of the gem if of the form ~> x.x.x, so we assume that it works also with new versions of Rails, until proved otherwise :)
Home page: github.com/simplificator/asset_pipeline_i18n