I am trying to create a multilingual website using the Django framework, all default content is English. I have added a native translation (Dutch).
https://mydomain.com/ redirects to the user request language setting. (This is default behaviour by adding Django's LocaleMiddleware)
LocaleMiddleware tries to determine the user's language preference by following this algorithm:
First, it looks for the language prefix in the requested URL. This is only performed when you are using the i18n_patterns function in your root URLconf. See Internationalization: in URL patterns for more information about the language prefix and how to internationalize URL patterns.
Failing that, it looks for a django_language key in the current user's session.
Failing that, it looks for a cookie.
The name of the cookie used is set by the LANGUAGE_COOKIE_NAME setting. (The default name is django_language.)
Failing that, it looks at the Accept-Language HTTP header. This header is sent by your browser and tells the server which language(s) you prefer, in order by priority. Django tries each language in the header until it finds one with available translations.
Failing that, it uses the global LANGUAGE_CODE setting.
So visiting '/' will result to either:
https://mydomain.com/en/ or https://mydomain.com/nl/
Title, description, keywords and content are language based so every page is (almost) entirely translated. So:
https://mydomain.com/en/my-awesome-page/
has a Dutch flag (language switch) that holds this link:
https://mydomain.com/nl/mijn-fantastische-pagina/
This works great. Also my page's header holds alternate content based upon the language variable, here's the pseudo code:
<html lang="{{ current_language }}" />
<head>
{% for lang_code in other_languages %}
<link rel="alternate" hreflang="{{ lang_code }}" href="{% url current_url language=lang_code %}"/>
{% endfor %}
</head>
This will result the english page to look like this:
<html lang="en" />
<head>
<link rel="alternate" hreflang="nl" href="https://mydomain.com/nl/mijn-fantastische-pagina/"/>
</head>
Now my problem is Google indexes my Homepage in english, while I want dutch visitors to see the dutch title and description in google's results (unless they look for the english translation).
I believe the problem might be due to auto redirecting the root url ('/') or automatically setting the language, should I exclude robots somehow? I have read this article but I haven't figured out the problem:
http://googlewebmastercentral.blogspot.nl/2010/03/working-with-multilingual-websites.html
Also if I add a site map to a multilingual site, would it be better to add a different sitemap for each language, or make one large tree based on language roots?