3

I am working on a multilingual website (php/mysql) and my question is what would be the best solution for language identification - sessions/cookies or URI identification. I mean in terms of SEO, what would be more accurate.

Thanks

Vasil Dakov
  • 2,040
  • 2
  • 19
  • 38

4 Answers4

4

There are different types of projects which shouldn't use the same language implementation.

Let me give some examples:

  1. The first project has an single domain name, let's say example.com. This website, should be available in three languages. In order to let the search engine clearly crawl and index each language - the correct solution here would be passing it by url. example.com/fr/ for french.

  2. The second project, has an domain name for each language, example.fr, example.co.uk. It would be best that each domain is only indexed by the search engine by it's primary language. Therefor, the solution I'd pick would be storing the language in a cookie when switching. (or redirect to the other domain entirely).

If we'd pick the solution of example 1 for example 2, both example.co.uk/fr/ and example.fr would have the same content, which isn't SEO friendly.

Wesley van Opdorp
  • 14,888
  • 4
  • 41
  • 59
  • In the context of the question both solutions are the same, because both just uses the URI. – KingCrunch May 17 '11 at 12:45
  • 1
    Second solution doesn't use the URI, it can be done using POST or detecting the user's language using it's ACCEPT_LANGUAGE. – Wesley van Opdorp May 17 '11 at 12:48
  • In my case I have a single domain for all languages and their corresponding translations. – Vasil Dakov May 17 '11 at 12:52
  • 1
    @Weslay: You suggest to use either "example.com/fr/" or "example.fr/", what is quite equivalent: One utilises the path, the other one the host, but both are part of the URI. What you describe in this comment with "_can_ be done", is possible with the first example too. – KingCrunch May 17 '11 at 12:55
  • Then solution 1 would be your perfect choice. Also read this for an good implementation as a whole http://www.google.com/support/webmasters/bin/answer.py?answer=182192 – Wesley van Opdorp May 17 '11 at 12:55
  • 1
    @King Ah I understand your comment now, I agree with your first comment. They are both different implementation types though, still useful (also for SEO). – Wesley van Opdorp May 17 '11 at 12:58
1

If you put the language into the URI a webcrawler can index the site in its different languages and users are able to bookmark/link to them. This is not possible, if there is no direct reference (=> URL) to the pages.

You can combine both ways: If no language specific information available within the URI, try to find it out from a cookie/session, and if this one fails, look at the Accept-Language-Header. Now, if one user change the language (by link or whatever) write it into a cookie (for later visits).

KingCrunch
  • 128,817
  • 21
  • 151
  • 173
1

URL. You can use something like a '/en/' prefix to all paths. Obviously you'd use mod_rewrite or appropriate framework routing config.

Aaria Carter-Weir
  • 1,639
  • 12
  • 17
1

Using only sessions/cookies, it wouldn't really be possible for someone to link straight to the 'Swahili' version of your content. Instead, you would have a default language (English?) which all incoming links would point to. Once there, if a user wanted your content in Mandarin then they could choose that option, but they won't get it straight out of the gate so using URI identification is my personal pick.

There are a couple of ways to tag what language to use in the URI, either by setting up some sort of directory structure, such as: http://domain.tld/localized/fr/ for the main page of the french content, or you can abstract it out in your database and identify the language through GET variables: http://domain.tld/?l=4 for the main page of language with ID of 4

Or, as Wesley van Opdorp pointed out, you can set up a separate domain or sub-domain for each language: http://domain.fr or http://fr.domain.tld

As far as SEO goes, I believe the best way would be to adhere to the Top Level Domain Standards and set up a separate domain for each language you want to host the site in (http://domain.fr, http://domain.ru, etc). This of course would mean purchasing more domains, so if that isn't an option my second choice would be to set up sub-domains for each langauge such as in: http://fr.domain.tld and http://ru.domain.tld

Jeff Lambert
  • 24,395
  • 4
  • 69
  • 96