Closed swayok closed 4 years ago
Thanks for that suggestion, could you make a PR? 😄
You should use:
public function apply($locale)
{
$this->translator->setLocale($locale);
$this->addCookieToQueue($locale);
$this->applyCallbacks($locale);
}
The method addCookieToQueue
already verify the usage of cookies.
Oops, my mistake!
Do as you wrote first
I've just had misunderstanding with usage of LanguageDetector::apply() method when I tried to replace locale manually due to user preferences. I was wondering why it did not work after page reload and digged into code where I found that cookie is not updated in apply() if it is already exist and I need to call addCookieToQueue() method to do that. I understand the reason behind this but it is not clear that I need to call addCookieToQueue() manually. I suggest to add $updateCookie = false argument to apply() so it will look like:
This will clarify the usage of apply() method