Jump to content

Recommended Posts

Posted (edited)

Hey,

back then when I changed the language part within the URL the page slug changed automatically in all directions.

Now it only changes from the primary language (in my case DE) to the secondary language (EN).

So:

/de/projekte > click on the lang switch > /de gets replaced with /en > /projekte changes automatically to /projects  => result: /en/projects  … great.

Changing back to /en does not work though:

/en/projects > click on the lang switch > /en gets replaced with /de > /projects does NOT change to /projekte  => result: url is not valid > page stays on /de/projects … not great.

So the auto page name translate only works from DE to EN not the other way around. As said it used to work flawlessly prior PW update.

Edited by sww
  • 3 months later...
Posted

@ryan Hi Ryan, is there no solution for this? This seems to be a serious bug. I can't be the only one experiencing this …

Cheers,
Stefan

Posted

How are you switching languages? Using javascript?

I tried on a test setup and I can indeed reproduce your issue by changing the URL in the browser the way you described but maybe you should instead rely on something like $page->localUrl to create your language switcher?

You can also raise your issue on Github, ideally by mentioning from which PW version you updated.

Posted

Hi,

being french, you can imagine that most my websites are multinlingual 🙂 and i alwys use this kind of language switcher

foreach($languages as $language)
{
    if( ! $page->viewable($language) ) continue;
    $url = $page->localUrl($language);
    $iso = $language->name == 'default' ? 'fr' : $language->name; // use your own default language instead of fr...
    if($language->id != $user->language->id)
    {
        echo '<a hreflang="' . $iso . '" href="' . $url . '" title="' . $language->title . '">' . $iso . '</a>' . "\n";
        // echo '<a hreflang="' . $iso . '" href="' . $url . '" title="' . $language->title . '"><img src="/site/assets/img/' . $iso . '.svg" alt="' . $language->title . '" /></a>' . "\n";
        // echo '<a hreflang="' . $iso . '" href="' . $url . '" title="' . $language->title . '">' . $language->title . '</a>' . "\n";
    }
    else
    {
        echo '<span>' . $iso . '</span>' . "\n";
        // echo '<span><img src="/site/assets/img/' . $iso . '.svg" alt="' . $language->title . '" /></span>' . "\n";
        // echo '<span>' . $language->title . '</span>' . "\n";
    }
}

and never ran into the issue you describe whether the urls are ...com/toto and ...com/en/toto or ...com/fr/toto and ...com/en/toto (in this case you have to give a name -the name you gave you default language- to the homepage, not the preferred way tu use pw but it works if necessary)
the two important things are the use of $url = $page->localUrl($language); like @monollonom says and the line where $language->name is defined for the default language

in case it may help 🙂

have a nice day

  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...