pimcore / demo

The Official Pimcore Demo Package - You're new to Pimcore? That's your entry point! 🤓
Other
101 stars 107 forks source link

[Bug]: Language Switcher on main pages doesn't work ?_locale=xx #517

Closed capitalfuse closed 1 year ago

capitalfuse commented 1 year ago

Expected behavior

ex) When change language from English to German on the main page; Links shows the following ---> 'https://demo.pimcore.com/?_locale=de' and not changed to the German site.

The following code has the main reason. src/Twig/Extension/LanguageSwitcherExtension.php

Actual behavior

It should be the following; 'https://demo.pimcore.com/de'

Steps to reproduce

Commented out the following codes, fixed, but it will affect the links of news document detail pages. src/Twig/Extension/LanguageSwitcherExtension.php

$route = $request->get('_route');
            $routeParams = $request->get('_route_params');

            if ($route && $routeParams) {
                $routeParams['_locale'] = \Locale::getPrimaryLanguage($language);
                $route = $this->urlGenerator->generate($route, $routeParams);
                $target = $route;
            }
kingjia90 commented 1 year ago

Thank you! Likely is a regression from https://github.com/pimcore/demo/pull/435

capitalfuse commented 1 year ago

I changed if condition like below.

if ($route && $routeParams['newstitle'] ) {
                $routeParams['_locale'] = \Locale::getPrimaryLanguage($language);
                $route = $this->urlGenerator->generate($route, $routeParams);
                $target = $route;
            }

---> But the above method has not been applied for the page view.

robertSt7 commented 1 year ago

It only works for static routes at the moment

dvesh3 commented 1 year ago

Fixed by #524