-
Notifications
You must be signed in to change notification settings - Fork 3
/
lang.php
66 lines (52 loc) · 1.56 KB
/
lang.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
56
57
58
59
60
61
62
63
64
65
66
<?
// The language localization helper
// requires $preferred_lang
// Configs
$DEFAULT_LOCALE_FLIE = 'locale/en.php';
$DEFAULT_LANG = "en";
if (!isset($preferred_lang)) {
$preferred_lang = $DEFAULT_LANG;
}
// include defalt and cache it first
include ($DEFAULT_LOCALE_FLIE);
$default_localize_string = $localized_string;
// Include preferred string array
$s_localefile = 'locale/' . $preferred_lang. '.php';
if (file_exists($s_localefile)) {
include ($s_localefile);
} else {
include ($DEFAULT_LOCALE_FLIE);
}
// Helper function
function META_TAGS_LOCALE($key) {
$meta_tags_array["en"] = "meta/en_US_meta.php";
$meta_tags_array["fr"] = "meta/fr_FR_meta.php";
$meta_tags_array["jp"] = "meta/ja_JP_meta.php";
$meta_tags_array["zh-hk"] = "meta/zh_HK_meta.php";
$meta_tags_array["kr"] = "meta/kr_KR_meta.php";
$meta_tags_array["de"] = "meta/de_DE_meta.php";
if (array_key_exists($key, $meta_tags_array)) {
return $meta_tags_array[$key];
} else {
return "meta/en_US_meta.php";
}
}
function LOCALE($key) {
global $localized_string;
if (isset($localized_string)) {
if (array_key_exists($key, $localized_string)) {
// successful find a localized string
return ($localized_string[$key]);
} else {
// oh, use default string
if (array_key_exists($key, $default_localize_string)){
return ($default_localize_string[$key]);
} else {
return ""; // cannot find localized string
}
}
} else {
return ""; // sorry ~ cannot find localized file
}
}
?>