Pa.multilingual - Meta "alternate" hreflang broken

Hi,
can someone help me to test and verify that?

We have a multilingual-site (de/en), pa.multilingual adds the following META links

On root (is correct)

<link rel="alternate" href="http://www.example.com/en/" hreflang="en">
<link rel="alternate" href="http://www.example.com/de/" hreflang="de">

But on subpage/folder (NOT Correct )

<link rel="alternate" href="http://www.example.com/en/is-is-page-1" hreflang="en">
<link rel="alternate" href="http://www.example.com/de/s-ist-seite-1" hreflang="de">

It should be "this-is-page-1" or "das-ist-seite-1"

On localhost:8080/Plone ... it is working

I think its this line

Quick fix (tested only with one site):

    for item in results:
        path_len = len('{0:s}/'.format(item.Language))
        url = item.getURL(relative=1)
        if url.startswith(portal_path):
            path_len = portal_path_len + len('{0:s}/'.format(item.Language))
        url = item.getURL(relative=1)[path_len:]
        alternates.append({
            'lang': item.Language,
            'url': url.strip('/'),
        })

Thanks for your help!

I use Plone 4.3.11 with plone.app.multilingual 2.0.2 and i can't verify your Problem. My Viewlet with the alternate Links looks ok.

Take a look at https://github.com/collective/collective.pamfixes. We created this for a customer some time ago.
There is also a GitHub issue.

The problem why this is not merged into p.a.m. is, if I remember correctly, the failing/missing tests.

1 Like

Thanks, I use now collective.pamfixes :slight_smile:

Seems like this would be worth pushing (again / more)...