jquery - rails javascript i18n specific yml using i18n-js plugin -
my question if there anyway configure i18n-js 1 specific .yml file being javascript not all. have followed example in below links , had javascript looking correct key;however, when @ translation.js plug in generated in inspect element, translation key shows up. worried issue our app grow since javascript needs know translation key needs. thinking have config/locales/en/javascript.yml put translation javascript in here.
followed example
https://github.com/fnando/i18n-js
http://blog.10to1.be/rails/2011/03/22/localizing-javascript-in-your-rails-app/
ran
rake i18n:js:setup application.js
//= require i18n //= require i18n/translations application.html.haml
= javascript_include_tag 'translation' directory
|config |-locales |--en |---en.yml |---javascript.yml <------ that's want , js @ one2
currently there no way of doing through simple configuration.
i18n-js agnostic of yml translation files or translation folders (such rails' default config/locales). asks i18n gem (which ships rails) retrieve available translations , export them js format.
you define custom rails environment, js_i18n, in overwrite default i18n load path such:
# config/environments/js_i18n.rb # code similar rest of config files - copy `development.rb` # ... config.i18n.load_path = dir[rails.root.join('config', 'locales', 'js', '*.{rb,yml}').to_s] and use environment load yml/ruby files under config/locales/js run whatever task like, such as:
rails_env=js_i18n rake i18n:js:export
Comments
Post a Comment