Fix x-default so that it uses the default language instead of the currently active language.

Merged
#3 · Created  · Last updated

Merged pull request

Merged in syastrov/django_hreflang (pull request #3)

24682f6·Author: ·Closed by: ·2018-04-13

Description

I have a project with default language set to German (LANGUAGE_CODE = 'de'). Am using the default Django LocaleMiddleware. In connection with that, I have a list of i18n_patterns in urls.py. In this example, I have used i18n_patterns(..., prefix_default_language=False), which is why the German URLs should be "/" instead of "/de/".

When visiting /en (e.g. a non-default language), I get this output, which is different from the output when visiting / (the same page in the default language):

<link rel="alternate" hreflang="x-default" href="/en/" /> <link rel="alternate" hreflang="de" href="/" /> <link rel="alternate" hreflang="en" href="/en/" />

x-default href should be "/" (The page in the default language).

After the fix, the result is:

<link rel="alternate" hreflang="x-default" href="/" /> <link rel="alternate" hreflang="de" href="/" /> <link rel="alternate" hreflang="en" href="/en/" />

Thanks for a nice project!

0 attachments

0 comments

Loading commits...