Skip to content

Instantly share code, notes, and snippets.

@psy-q
Created May 14, 2012 12:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save psy-q/2693734 to your computer and use it in GitHub Desktop.
Save psy-q/2693734 to your computer and use it in GitHub Desktop.
I18n.locale = --> setting this is ignored
From: /home/rca/work/code/ror/leihs/app/controllers/application_controller.rb @ line 65 ApplicationController#set_gettext_locale:
60: current_user.language = language # language is a protected attribute, it can't be mass-asigned via update_attributes
61: current_user.save
62: current_user.reload
63: end
64: locale_symbol = current_user.language.locale_name.to_sym
=> 65: binding.pry
66: else
67: locale_symbol = Language.default_language.locale_name.to_sym
68: end
69:
70: I18n.locale = locale_symbol
[1] pry(#<Backend::InventoryPoolsController>)> locale_symbol
=> :"de-CH"
[2] pry(#<Backend::InventoryPoolsController>)> I18n.locale
=> :en_GB
[3] pry(#<Backend::InventoryPoolsController>)> I18n.locale = locale_symbol
From: /home/rca/.rvm/gems/ruby-1.9.2-p320/gems/fast_gettext-0.6.6/lib/fast_gettext/storage.rb @ line 187 FastGettext::Storage#format_locale:
187: def format_locale(locale)
188: #locale.sub(/^([a-zA-Z]{2})[-_]([a-zA-Z]{2})$/){$1.downcase+'_'+$2.upcase}
189:
190: #locale.sub(/^([a-zA-Z]{2})([-_])([a-zA-Z]{2})$/){$1.downcase+'$2'+$3.upcase}
191:
=> 192: binding.pry
193: locale.sub(/^([a-zA-Z]{2})[-_]([a-zA-Z]{2})$/){$1.downcase+'-'+$2.upcase}
194: end
[1] pry(FastGettext)> locale.sub(/^([a-zA-Z]{2})[-_]([a-zA-Z]{2})$/){$1.downcase+'-'+$2.upcase}
=> "de-CH"
[2] pry(FastGettext)> exit
=> :"de-CH"
[4] pry(#<Backend::InventoryPoolsController>)> I18n.locale
=> :en_GB
[5] pry(#<Backend::InventoryPoolsController>)>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment