-
Notifications
You must be signed in to change notification settings - Fork 143
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
Root path displaying controller name #205
Comments
Hi! Thanks for being part of the route_translator community. Please use this approach:
If you are interested in how to generate translated routes, please take a look at our wiki: https://github.com/enriclluelles/route_translator/wiki/Generating-translated-URLs PS:
Is this a before filter? I do not advise to use a before filter. Please check the implementation of the around filter we are using: https://github.com/enriclluelles/route_translator/blob/v7.1.1/lib/route_translator/extensions/action_controller.rb#L12-L23 |
Hi @tagliala - The language switcher is global in my header, so your implementation will only work for the home page. If a user is on the about page for instance, it will take them back to root if they switch language. Yes, set_locale is set with a before_action call. Based on your code snippet though, I am not sure what I need to do? |
Please note that this is not so simple. The wiki covers the simplest case (first paragraph) => https://github.com/enriclluelles/route_translator/wiki/Generating-translated-URLs
Please turn it in an around action, because of locale leaking between requests on some web servers => #44 |
Ok thank you, I could just check if the current page is root as well in my language links. Do you have any other recommendations? |
Not sure why the controller name is displaying for the root path when a user clicks on the language switcher? Do I need to set a path for articles?
eg:
resrouces :articles, path '' ?
Steps to reproduce*
routes.rb
index.html.erb
Expected behavior*
localhost/fr
Actual behavior*
localhost/fr/articles
System configuration*
Rails version: 6.0.0
Replace with output of
rails -v
Ruby version: 2.6.4
Replace with output of
bundle exec rails -v
Route Translator version: 7.0.1
Replace with output of
cat Gemfile.lock | grep route_translator
I18n configuration*
application controller
Thank you for your help.
The text was updated successfully, but these errors were encountered: