0

Is there any way to know the client machines language settings? specifically the List separator (Delimiter) selected. Because, in my project website (Developed using PHP, Javascript, Jquery) the client can export reports in csv format. At present we are creating this csv with "comma" as the delimiter. But for some of our clients , when they open this CSV the datas are showing in one column itself with comma separated.

I understood this is because the default List separator selected in their OS control panel configuration may be a different delimiter than comma. However, we don't want to tell to every client to change their OS configuration.. Is there any other solution for this? If i generate xls file instead of csv this same issue will come in future right???

Zammuuz
  • 708
  • 4
  • 18
  • 43
  • Take a look at the answer in http://stackoverflow.com/questions/1011628/detecting-regional-settings-list-separator-from-web#2812853 – rypskar Aug 08 '16 at 11:00

1 Answers1

0

Try this function

function getUserLanguage() {
  $langs = array();
  if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
 // break up string into pieces (languages and q factors)
 preg_match_all('/([a-z]{1,8}(-[a-z]{1,8})?)\s*(;\s*q\s*=\s*(1|0\.[0-9]+))?/i',
$_SERVER['HTTP_ACCEPT_LANGUAGE'], $lang_parse);
if (count($lang_parse[1])) {
// create a list like â??enâ?? => 0.8
$langs = array_combine($lang_parse[1], $lang_parse[4]);
// set default to 1 for any without q factor
foreach ($langs as $lang => $val) {
if ($val === '') $langs[$lang] = 1;
}
// sort list based on value
arsort($langs, SORT_NUMERIC);
 }
}
//extract most important (first)
foreach ($langs as $lang => $val) { break; }
//if complex language simplify it
if (stristr($lang,"-")) {$tmp = explode("-",$lang); $lang = $tmp[0]; }
return $lang;
}
Bibek Jana
  • 104
  • 8