-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetLocale.php
55 lines (51 loc) · 1.94 KB
/
setLocale.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
header('Content-Type: application/json');
$locale = locale_accept_from_http($_SERVER['HTTP_ACCEPT_LANGUAGE']);
//setlocale(LC_ALL, 'vi_VN');
setlocale(LC_ALL, $locale);
$localeInfo = localeconv();
$intCurSymbol = str_replace(" ", "", $localeInfo['int_curr_symbol']);
$currencySymbol = $localeInfo["currency_symbol"];
$pCsPrecedes = $localeInfo["p_cs_precedes"];
$thousandsSep = $localeInfo["thousands_sep"];
if($thousandsSep == "")
{
$thousandsSep = " ";
}
$decimalPoint = $localeInfo['decimal_point'];
$intFracDigits = $localeInfo["int_frac_digits"];
$monDecimalPoint = $localeInfo['mon_decimal_point'];
$monThousandsSep = $localeInfo['mon_thousands_sep'];
$mask_hundd = " 000" . $decimalPoint . str_repeat("0", intval($intFracDigits)) . "000";
$mask_thousd = " 00" . $decimalPoint . str_repeat("0", intval($intFracDigits)) . "00";
$mask_d = " 0" . $decimalPoint . str_repeat("0", intval($intFracDigits)) . "0'";
$mask_hund = " 000" . $thousandsSep . "000" . $decimalPoint . str_repeat("0", intval($intFracDigits)) . "";
$mask_thous = " 00" . $thousandsSep . "000" . $decimalPoint . str_repeat("0", intval($intFracDigits)) . "00";
$mask_ = " 0" . $thousandsSep . "000" . $decimalPoint . str_repeat("0", intval($intFracDigits)) . "0";
if ($intFracDigits > 0) {
$maskval = "500";
$decimal = "true";
} else {
$mask = "00000";
$maskval = "500";
$decimal = "false";
}
$data = [
'intCurSymbol' => $intCurSymbol,
'currencySymbol' => $currencySymbol,
'pCsPrecedes' => $pCsPrecedes,
'thousandsSep' => $thousandsSep,
'decimalPoint' => $decimalPoint,
'intFracDigits' => $intFracDigits,
'monDecimalPoint' => $monDecimalPoint,
'monThousandsSep' => $monThousandsSep,
'maskval' => $maskval,
'decimal' => $decimal,
'mask_thousd' => $mask_thousd,
'mask_hundd' => $mask_hundd,
'mask_thous' => $mask_thous,
'mask_hund' => $mask_hund,
'mask_d' => $mask_d,
'mask_' => $mask_
];
echo json_encode($data);