Set user language depending on country code?

×

Missatge d'estat

You are not a member of this team. If you want to be part of this team, click on 'Subscribe to this team'.
Tipus: 
Feature request
Due date: 
dimarts, gener 15, 2019 - 18:00
Estat: 
In progress
Prioritat: 
Normal
Descripció: 

Hi Jordi,

may-be deep in our wish list this request is still recorded? Many German user write to me contact mails in English. This is showing me that they were not aware that our homepage can be switched to German.

Is it much work to recognize the country, where a user is located? And switch the language of our homepage accordingly to his (country) language?

There are countries like Switzerland, having several languages. So may-be instead of country code the language of the browser or OS would work better?

It would be important for DACH area, I am sure. Thank you.

Ralf

Hi all,
you can detect the language of the browse in many ways.

If your provider allow, use this script and find the language of the user, you can add this to https://www.labdoo.org/de

-->

A second script I used to find out more from the incomming website I have attached it for you.

If you use PHP use this script:

/**
* Detect Browser Language
*/
function getPreferredLanguage(){

$acceptedLanguages = @explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
$preferredLanguage = null;
$maxWeight = 0.0;

foreach((array)$acceptedLanguages as $acceptedLanguage){

$weight = (float)@substr(explode(';', $acceptedLanguage)[1], 2);
if(!$weight){$weight = 1.0;}

if($weight > $maxWeight){
$preferredLanguage = substr($acceptedLanguage, 0, 2);
$maxWeight = $weight;
}
}

return $preferredLanguage;
}

Comentaris

imatge de jordi
Enviat per jordi el dg., 01/13/2019 - 22:07

This ticket is now resolved. Could you please verify that the automatic language detection based on the user Browser settings works correctly? e.g., if your browser settings are in German, it should automatically switch to the German translation, the same for any other supported languages.

imatge de jordi
Enviat per jordi el dl., 01/21/2019 - 05:07

Hi, I had to temporarily disabled this feature because a latent bug on forwarding edoovillage's scrapbooks URL based on language popped up when the automatic switch language is enabled. I will need to fix that bug before i can enable back this feature, i will do so soon and communicate through this ticket once it's resolved, thanks.