Skip to content
Advertisement

i18n_patterns: How come some user are accessing /en-us/ where what I have is /en/

I am using i18n_patterns for my URL and yesterday when I launched the live site I noticed through Google Analytics many people are accessing http://www.example.com/**en-us**/ instead of http://www.example.com/**en**/. I do not have http://www.example.com/**en-us**/ link anywhere on my site.

Personally, when I try to access the site through http://www.example.com/ I am redirected to http://www.example.com/**en**/ which is the wanted behaviour. Also when I try http://www.example.com/**en-us**/ I get a not found page, which is also what I want, since it’s not good for SEO to have multiple URls for the same page.

Now the weird is I am actually seeing visitors at /en-us/ because I do not have Google Analytics on the not found page yet!

This is part of my settings:

LANGUAGE_CODE = 'en-us'

gettext = lambda s: s
LANGUAGES = (
    ('en', gettext('English')),
    ('fr', gettext('French')),
    ('es', gettext('Spanish')),

Any idea what is causing that? Are these people getting a not found page, and how can I eliminate the issue? It’s really hard to debug it when it is not happening to me!

Advertisement

Answer

LANGUAGE_CODE = 'en-us'

This sets the default, if no acceptable language is found. See the documentation for details.

If you don’t have an en-us translation, then don’t set that to be your default – set it to en or similar.

It’s really hard to debug it when it is not happening to me!

You can probably recreate the bug by setting your language preference for your browser to American English, or to a language that you haven’t localised for.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement