Railsã§Backboneã使ããªããDRYã«i18n
ããã使ãã°OKç§å ´ã
https://github.com/fnando/i18n-js
Gemfile
gem 'i18n-js'
application.js
//= require i18n //= require i18n/translations
configãã¡ã¤ã«çæ
bundle exec rake i18n:js:setup
â»ãã³ãã¯ãã®ããã»ã¹ã¯è¦ããªãã®ã ãã©ãsprocketã®ãã°ã®ããã§å¿ è¦ããããhttps://github.com/fnando/i18n-js/issues/71
application.html.erb
<script type="text/javascript"> I18n.defaultLocale = "<%= I18n.default_locale %>"; I18n.locale = "<%= I18n.locale %>"; </script>
ããã ãã§ã¡ããã¨Railsã®config/localesä¸ã®è¨èªãã¡ã¤ã«ããã®ã¾ã¾ä½¿ããããã«ãã¦ãããï¼ï¼ï¼
â»Webrickã¨ãèµ·åããã£ã±ãªãã®äººã¯ä¸åº¦åèµ·åãã
ã§ãã©ã£ãã§
console.log I18n.t("common.title")
ã¨ããã£ã¦ããã±ã¼ã«ããã¦ã¢ã¯ã»ã¹ãã¦ããããªããã
Railsã®I18nã¨ããªãããªããã¨ãã§ããã£ã½ãã®ã§ãREADMEãèªãã§ã¿ã¦ã¡ãã
ããã¼ã楽ã ãã¼ã