Skip to content
New issue

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

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

Already on GitHub? # to your account

Craft::$app->getLocale() not working properly on live preview #3336

Closed
jlachancekffein opened this issue Oct 1, 2018 · 1 comment
Closed

Comments

@jlachancekffein
Copy link

Description

On live preview mode the result of the method Craft::$app->getLocale() not return the locale of the target entry page url. The method return the locale of the Cp Panel, not the entry site selected.

On our website, we have two site configured with locales (fr-ca, en-ca). The CP is configured with the locale (fr). When we visit the site with the live preview mode button, an error is throw when we valide for a valid site locale (in our case fr-ca pr en-ca). The error us causing by the fact that the locale is set to (fr).

I understand that in the CP panel, the locale used is the locale configured in the user settings. But in live preview, it suppose to use the locale defined in the url ex : http://mysite.com/{locale}/{slug}.

Maybe Craft::$app->getLocale() is not the method needed to be used for getting the locale properly in all case ?

Steps to reproduce

  1. Create two site via CP with two different locale
  2. Create an admin user with another locale defined in the site settings
  3. Create a entry related to any site
  4. Relate the entry section to a template
  5. Dump a call to Craft::$app->getLocale() in the template
  6. Validate that the locale is not in the list of the sites locales

Additional info

  • We use a module variable that is used in a template for output the locale.
@brandonkelly
Copy link
Member

Thanks for reporting that! Fixed for the next release.

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

No branches or pull requests

2 participants