开发者

In rails, Generating a language hash using localization, how to cache?

Usin开发者_如何学编程g the locales yml files, I want to pre-generate a javascript hash that contains key/value pairs that I will use in my javascript files when displaying messages in the UI.

How can I generate this hash file so I can do:

lang["must_be_logged_in"]

and it will output:

"Sorry, you have to login first"

So when a user visites the page, I will lookup the local they want, and then in my application.html.erb file I will inject the javascript hash of all language key/value pairs that my other .js files will be referencing.


Use i18n-js. See this answer for more details.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜