Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set default locale in rails

Tags:

How do I set the default locale in rails application.rb so I don't have to add unit every time I call the following?

number_to_currency(@course.price, unit: "£") 

Rails guides says my locale is :en-GB for the UK, but the following obviously creates an error in application.rb

config.i18n.default_locale = :en-GB
like image 440
raphael_turtle Avatar asked Jul 23 '14 11:07

raphael_turtle


2 Answers

The rails-i18n gem contains a lot of locale configurations for Rails and en-GB is one of them. en-GB isn't included in Rails itself.

  1. Add the rails-i18n gem
  2. Add config.i18n.default_locale = :'en-GB' to application.rb
like image 99
Alistair Holt Avatar answered Oct 11 '22 17:10

Alistair Holt


Try this:

config.i18n.default_locale = :'en-GB'
like image 30
Marek Lipka Avatar answered Oct 11 '22 18:10

Marek Lipka