Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changing language #45

Open
tigus opened this issue Oct 9, 2013 · 5 comments
Open

changing language #45

tigus opened this issue Oct 9, 2013 · 5 comments

Comments

@tigus
Copy link

tigus commented Oct 9, 2013

Hello,

i would like make links to change language of website
But currently i can't have url translated by language in these links
all links are in the same language (the current of course

how force to use a other language than current

I18n.available_locales.each do |locale|
new_params = params.merge(:locale => locale)
content += content_tag(:li, link_to(locale.to_s.upcase, new_params))
end

tx

@pbr-pl
Copy link

pbr-pl commented Oct 26, 2013

I've got the same problem. Let us know if you solve it

@tigus
Copy link
Author

tigus commented Oct 26, 2013

i found a "trick" but very dirty
current_locale = I18n.locale
I18n.available_locales.each do |locale|
new_params = params.merge(:locale => locale)
I18n.locale = locale
content += content_tag(:li, link_to(locale.to_s.upcase, new_params))
end
I18n.locale = current_locale

like a said it works but it's no a nice solution
unfortunatly i choose a other gem

@pbr-pl
Copy link

pbr-pl commented Oct 26, 2013

I solved it little bit less "dirty" way. Just not switching I18n.locale but useing I18n.with_locale

I18n.available_locales.each do |locale|
    content += content_tag(:li, I18n.with_locale(locale){link_to(locale.to_s.upcase, url_for(:locale => locale))})
end

@dbarison
Copy link

dbarison commented Nov 5, 2013

didnt' work for me. The list was printed correctly, but after that links are broken in my app with random locales.
Any suggestion?

@pbr-pl
Copy link

pbr-pl commented Nov 5, 2013

  1. suggestion is: check your translation files.
  2. explain what does it mean - "links are broken". This can make suggestion change. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants