techiferous / tabulous

Easy tabbed navigation for Rails
Other
322 stars 35 forks source link

Link to locale #49

Closed hquick81 closed 10 years ago

hquick81 commented 10 years ago

Hi,

is there any way to link to a locale like i would do normally with

<%= link_to locale: "de" do %>
  <img src="/assets/flags/de.png" width="16" height="11" alt="DE Language" /> [DE] Deutsch
<% end %>

Thx and greetings

Holger

hquick81 commented 10 years ago

Now after a little bit thinking and trying arround i came up with the following solution:

    language_tab do
      text          { "<img id=\"current_lang\" src=\"/assets/flags/#{I18n.locale}.png\" width=\"16\" height=\"11\" />" }
      link_path     { "" }
      visible_when  { true }
      enabled_when  { true }
      active_when   { false }
      active_when { a_subtab_is_active }
    end

    de_language_subtab do
      text          { '<img src="/assets/flags/de.png" width="16" height="11" /> [DE] Deutsch' }
      link_path     { url_for(:locale => :de) }
      visible_when  { true }
      enabled_when  { true }
      active_when   { false }
    end

    en_language_subtab do
      text          { '<img src="/assets/flags/en.png" width="16" height="11" /> [US] English' }
      link_path     { url_for(:locale => :en) }
      visible_when  { true }
      enabled_when  { true }
      active_when   { false }
    end

Thx for this gem !

techiferous commented 10 years ago

Glad you figured it out! Also, if you don't want to hard-code the HTML, you can extract the link_to into a view helper and call that view helper inside the text { } declaration.