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

Mobility.with_locale(:de) not working in feature specs #98

Closed
jmuheim opened this issue Sep 17, 2017 · 11 comments
Closed

Mobility.with_locale(:de) not working in feature specs #98

jmuheim opened this issue Sep 17, 2017 · 11 comments
Labels

Comments

@jmuheim
Copy link

jmuheim commented Sep 17, 2017

When I'm doing the following:

Mobility.with_locale(:de) do
  visit page_path(@page)
end

...then the default locale (en) is still active. It only works like so:

visit page_path(@page, locale: :de)
@shioyama
Copy link
Owner

This is really a question for SO, but just quickly: Mobility.locale is not the same as I18n.locale. Setting Mobility.locale will take effect for Mobility stuff, but not for stuff that's looking at I18n.locale since that locale does not change.

If you want to change the I18n locale, you need to use I18n.with_locale(:de). If Mobility.locale is nil, then Mobility will also default to I18n.locale.

@jmuheim
Copy link
Author

jmuheim commented Sep 17, 2017

You're right, I wasn't aware of this difference. I'm sorry for polluting your issues tracker. Next time I'll ask on SO. 👍

@jmuheim
Copy link
Author

jmuheim commented Sep 17, 2017

(Thanks though!)

@shioyama
Copy link
Owner

No worries! The readme could be clearer about this.

@jmuheim
Copy link
Author

jmuheim commented Sep 17, 2017

PS: I18n.with_locale :de { ... } doesn't seem to work either. Maybe it's running in a different thread or something...?

@shioyama
Copy link
Owner

I think you need do/end for that to work.

@jmuheim
Copy link
Author

jmuheim commented Sep 17, 2017

I did... I just replaced it with curly braces to make a one-liner here. 😅

@shioyama
Copy link
Owner

hmm not really sure, you mean mobility is not showing translations in German?

@jmuheim
Copy link
Author

jmuheim commented Sep 17, 2017

No, the Rails routing mechanism still sent me to the english page.

@shioyama
Copy link
Owner

Well, that's really not a Mobility issue at all...

@jmuheim
Copy link
Author

jmuheim commented Sep 17, 2017

Exactly. Just wanted to point it out here for someone else coming from Google or so... 👍

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

No branches or pull requests

2 participants