Chris Hilton
Chris Hilton

Reputation: 717

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?

Upvotes: 6

Views: 2568

Answers (1)

pjam
pjam

Reputation: 6356

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

Upvotes: 8

Related Questions