当前位置: 动力学知识库 > 问答 > 编程问答 >

Rails 3 available_locales excluding gem translations

问题描述:

I have a Rails 3 app in which I'm using I18n.available_locales to display a list of available languages for user accounts. In my config/locales directory I only have en and nl yml files, however, I18n.available_locales returns a variety of other locale keys which I'm assuming are present due to translations being present in the gems that I'm using. Is there a common/standard way to get the method to only return the translations present in the app itself?

网友答案:

I would suggest, you use this gem : rails-i18n , it provides basic translations for every languages, and then, restrict available locales with

config.i18n.available_locales = ['es-CO', :de]

Of course, rails-i18n is not mandatory here, you could simply define available_locales in your config/application.rb file

And as said in the comments, you should definitely accept some answers to improve your accept_rate

分享给朋友:
您可能感兴趣的文章:
随机阅读: