-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathlocale.php
More file actions
34 lines (26 loc) · 722 Bytes
/
locale.php
File metadata and controls
34 lines (26 loc) · 722 Bytes
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
<?php
//Default to English
$locale = 'en_US';
$languages = ($_SERVER['HTTP_ACCEPT_LANGUAGE']);
$languages = str_replace( ' ', '', $languages );
$languages = str_replace( '-', '_', $languages );
$languages = explode( ",", $languages );
//print "Locales = ";
//print_r($languages);
//print " <br>";
foreach ( $languages as $temp) {
$temp = substr($temp,0,5);
$trans = './locale/'.$temp.'/LC_MESSAGES/messages.mo';
//print "Looking for locale in $trans <br>";
if ( ($temp == "en_us") || file_exists($trans)) {
$locale = $temp;
break;
}
}
setlocale(LC_ALL, $locale);
// Specify location of translation tables
bindtextdomain("messages", "./locale");
// Choose domain
textdomain("messages");
//echo $locale;
?>