Created
February 10, 2013 12:49
-
-
Save yoavmatchulsky/4749498 to your computer and use it in GitHub Desktop.
Fix for setting a he locale (/he prefix) to named routes.
Bug was that #url_for called from views didn't get the correct locale.
Solved by set_locale if @locale.nil in #default_url_options
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def set_locale | |
if @locale.nil? | |
I18n.locale = params[:locale] || I18n.default_locale | |
@locale = I18n.locale.to_sym | |
end | |
end | |
def default_url_options(options = {}) | |
set_locale if @locale.nil? | |
if [:he].include? @locale | |
options.reverse_merge locale: @locale | |
else | |
options | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment