FYI, here is the working code :

function set_guest_lang(&$pun_user)
{
  if ($pun_user['g_id'] != PUN_GUEST)
    return;
  if (!isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
    return;
  $acclang = substr(strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']),0,2);
  $lang = $pun_user['language'];
  if ($acclang == "fr") { // prefer fr 
    $lang = 'French';
  } else if ($acclang == "en") { // prefer en
    $lang = 'English';
  } else if ($acclang == "de") { // prefer de
    $lang = 'German';
  } else if ($acclang == "es") { // prefer es
    $lang = 'Spanish';
  } else if ($acclang == "pt") { // prefer pt
    $lang = 'Portuguese';
  } else if ($acclang == "ru") { // prefer ru
    $lang = 'Russian';
  } else if ($acclang == "it") { // prefer it
    $lang = 'Italian';
  } else if ($acclang == "ro") { // prefer ro
    $lang = 'Romanian';
  } else if ($acclang == "pl") { // prefer pl
    $lang = 'Polish';
  } else if ($acclang == "tr") { // prefer tr
    $lang = 'Turkish';
  } else { //default
    $lang = 'English';
  }  
  $pun_user['language'] = $lang;
}

Cheers

In my quest to Detect the language of anonymous users (see :
http://punbb.org/forums/viewtopic.php?id=2534 )

I found this on http://wiki.punres.org/Detect_the_langu … mous_users

add this function to include/functions.php

// use User-Agent language to determine language for guests
// arg is associative array, sets ['language'], uses ['g_id']
// Mod by Han-Kwang Nienhuys, 2006-2007
function set_guest_lang(&$pun_user)
{
  if ($pun_user['g_id'] != PUN_GUEST)
    return;
  if (!isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
    return;
  $acclang = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
  $lang = $pun_user['language'];
  if (preg_match('/sv.+nl/', $acclang)) { // prefer sv above nl
    $lang = 'Svenska';
  } else if (preg_match('/nl.+sv/', $acclang)) { // prefer nl above sv
    $lang = 'Nederlands';
  } else if (preg_match('/sv/', $acclang)) { // knows sv, not nl
    $lang = 'Svenska';
  } else if (preg_match('/nl/', $acclang)) { // knows nl, not sv
    $lang = 'Nederlands';
  }
  $pun_user['language'] = $lang;
}

And then find this in include/common.php :
// Check/update/set cookie and fetch user info
$pun_user = array();
check_cookie($pun_user) ; and add this below it:

set_guest_lang($pun_user);

As I just want the laguage to be detected, I tried to modify the code to :

// use User-Agent language to determine language for guests
// arg is associative array, sets ['language'], uses ['g_id']
// Mod by Han-Kwang Nienhuys, 2006-2007
function set_guest_lang(&$pun_user)
{
  if ($pun_user['g_id'] != PUN_GUEST)
    return;
  if (!isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
    return;
  $acclang = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
  $lang = $pun_user['language'];
if (preg_match('/fr/', $acclang)) { // knows fr
    $lang = 'French';
  } else if (preg_match('/it/', $acclang)) { // knows en
    $lang = 'Italian';
  } else if (preg_match('/de/', $acclang)) { // knows de
    $lang = 'German';
  } else if (preg_match('/sp/', $acclang)) { // knows sp
    $lang = 'Spanish';
  } else if (preg_match('/pe/', $acclang)) { // knows pe
    $lang = 'Portuguese';
  } else if (preg_match('/ru/', $acclang)) { // knows ru
    $lang = 'Russian';
  } else { //default
    $lang = 'English';
  }
  $pun_user['language'] = $lang;
}

But it doesn't work (I don't much about PHP), would someone please let me know what I have done wrong ?

I have all translations installed.

Thanks in advance.

See, also :
http://punbb.org/forums/viewtopic.php?id=16350
http://punbb.org/forums/viewtopic.php?id=17015

May be not the best answer, but have a look at this :
http://wiki.punres.org/Detect_the_langu … mous_users

See, also :
http://punbb.org/forums/viewtopic.php?id=16350
http://punbb.org/forums/viewtopic.php?id=17015

May be not the best answer, but have a look at this :
http://wiki.punres.org/Detect_the_langu … mous_users

See, also :
http://punbb.org/forums/viewtopic.php?id=16350
http://punbb.org/forums/viewtopic.php?id=17015

May be not the best answer, but have a look at this :
http://wiki.punres.org/Detect_the_langu … mous_users

Hello,

What I am looking for is the following :

For guest (and only guest), if browser is configurated with english, then forum is english. If the guest's browser is russian, then forum environment is russian.

Is there any one that could help me trying to install this on my forum ?

It seems to me that posted code in this thread does not look up to date any more.

I posted in http://www.punbb.fr/forums/viewtopic.php?id=3062 , but it seems the french are not up to do it.

Any one else ?

Thanks in advance.