-
Notifications
You must be signed in to change notification settings - Fork 50
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 takes always application default locale #30
Comments
Usually (in documentation examples) the set_locale method takes the params locale or the browser locale, yours take the params locale (none in the case of root) or default app locale, so the behaviour is correct. I suggest you to use the first method mentioned, params locale and browser locale.
|
Thanks for you reply really stuck on that issue. @@francesc the params[:locale] on root is not none as you mentioned above its always "de" so the behavior is not correct |
It's always "de" because params locale is empty and you default to I18n.default_code (which I suppose is de for you), first time in root path where you don't have a translated segment to detect the locale or you don't have localized root (/de) you have to guess the language, first thing to try is params locale, then if it's empty second logical option is to use user browser locale (which you don't), and then finally to app default. I really don't understand where's the problem. If you make a more detailed explanation of what you want to achieve I'll try to help you. |
Ok.Let me clear more. On root_path I am getting the params[:locale] is always "de". It should be empty as you mentioned. I am taking about params not i18n as you were assuming i think (It's always "de" because params locale is empty) |
Sorry haven't noticed you're using :no_prefixes => true you should extend set_locale method to use browser detection first on root path. |
I have the same problem... how can i do to set locale for the root_path ? ;) |
I have translated my app in two languages using Rails 3.2.6, de and en. Setting the locale in Application Controller:
before_filter :set_locale
def set_locale
I18n.locale = params[:locale] || I18n.default_locale ##for root_path params[:locale]=de(default locale) always
end
add in the routes.rb
ActionDispatch::Routing::Translator.translate_from_file('config/locales/routes.yml',{:no_prefixes => true })
Everything working fine except on the root_path the locale is not setting. Take always application default locale.
Please let me know any solution for this.
Thanks.
The text was updated successfully, but these errors were encountered: