forked from coral-erm/coral
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LangCodes.php
34 lines (33 loc) · 1.01 KB
/
LangCodes.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
<?php
/**
* @author: Cesar Hernandez
* getLanguage: This method return the name of the language according to the language code
*/
class LangCodes{
public function getLanguage($code){
$all_lang=array(
'fr_FR'=>'fr_FR',
'en_GB'=>'en_US',
'en_US'=>'en_US',
'zh_CN'=>'zh_CN',
'zh_TW'=>'zh_TW',
'de_DE'=>'de_DE'
);
return array_key_exists($code, $all_lang) ? $all_lang[$code] : "en_US";
}
public function getNameLang($code_lang){
$name_lang=array(
'fr_FR'=>'Français',
'en_GB'=>'English (GB)',
'en_US'=>'English (US)',
'zh_CN'=>'中文 (简体)',
'zh_TW'=>'中文 (正體)',
'de_DE'=>'Deutsch'
);
return array_key_exists($code_lang, $name_lang) ? $name_lang[$code_lang] : "English";
}
public function getBrowserLanguage() {
return str_replace('-', '_', substr($_SERVER["HTTP_ACCEPT_LANGUAGE"],0,5));
}
}
?>