Skip to content

Commit

Permalink
wrapped up site bar translation locale logic into a method.
Browse files Browse the repository at this point in the history
  • Loading branch information
parndt committed Mar 16, 2011
1 parent 57ef8bc commit c686251
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion core/app/views/shared/_site_bar.html.erb
Expand Up @@ -18,7 +18,7 @@
<%= RefinerySetting.find_or_set(:site_name, 'Company Name') %>
</span>

<%= link_to t('.log_out', :locale => (defined?(::Refinery::I18n) ? ::Refinery::I18n.current_locale : :en)),
<%= link_to t('.log_out', site_bar_translate_locale_args),
destroy_user_session_path, :id => 'logout' %>
</div>
</div>
Expand Down
12 changes: 10 additions & 2 deletions core/lib/refinery/helpers/site_bar_helper.rb
Expand Up @@ -4,13 +4,13 @@ module SiteBarHelper

# Generates the link to determine where the site bar switch button returns to.
def site_bar_switch_link
link_to_if(admin?, t('.switch_to_your_website', :locale => (defined?(::Refinery::I18n) ? ::Refinery::I18n.current_locale : :en),
link_to_if(admin?, t('.switch_to_your_website', site_bar_translate_locale_args),
(if session.keys.include?(:website_return_to) and session[:website_return_to].present?
session[:website_return_to]
else
root_path(:locale => (::Refinery::I18n.default_frontend_locale if defined?(::Refinery::I18n) && ::Refinery::I18n.enabled?))
end)) do
link_to t('.switch_to_your_website_editor', :locale => (defined?(::Refinery::I18n) ? ::Refinery::I18n.current_locale : :en)),
link_to t('.switch_to_your_website_editor', site_bar_translate_locale_args),
(if session.keys.include?(:refinery_return_to) and session[:refinery_return_to].present?
session[:refinery_return_to]
else
Expand All @@ -19,6 +19,14 @@ def site_bar_switch_link
end
end

def site_bar_translate_locale_args
if defined?(::Refinery::I18n)
{:locale => ::Refinery::I18n.current_locale}
else
{}
end
end

end
end
end

0 comments on commit c686251

Please sign in to comment.