Frage

I have a website that is avaliable in two languages, english and portuguese.

The website is configured so that the Google +1 button likes count is the same no matter what the language the reader is reading the web site, but this gives me a problem, because I must choose only one URL for the Google +1 button, which will be in only one of the avaliable languages: portuguese or english, not both. Examples of the URLs that I use to configure the Google +1 button URL (href) are below:

Portuguese url: www.website.net/the-page

English url: www.website.net/en/the-page

With this, when the user click on the Google +1 button, she ends up sharing the page in the language that was configured in the Google +1 button, which may not be in the same language preferred by the user.

To make things clearer, these are currently the possible scenaries of liking my website with the Google +1 button:

1. Google +1 configured with the english URL version: brazilian users would share the post/page in english (BAD!), and american users would share the post in english (OK).

2. Google +1 configured with the portuguese URL version: brazilian users would share the post/page in portuguese (good), but american users would share the post in portuguese (not OK).

How can I (if it is possible) make Google +1 button likes count be the same for both languages and still let the user share the page in his/her own preferred language?

War es hilfreich?

Lösung

I don't think there is any way to have the +1 button share different URLs but have the same count, so you need some way of determining the language to display that is not based on the URL. The best way to do this is to examine the "Accept-Language" header from the HTTP request, and serve up the portuguese page if the language is pt, and the english version otherwise. Something like the following (untested code) on www.website.net/the-page:

if ($_SERVER['HTTP_ACCEPT_LANGUAGE'] != 'pt') {
  header('Location: /en/the-page');
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top