Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 981
Chris Hilton Avatar asked Jan 08 '13 09:01

Chris Hilton


1 Answers

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

like image 163
pjam Avatar answered Oct 14 '22 00:10

pjam