1 | <?php |
||
20 | class Lang |
||
21 | { |
||
22 | /** |
||
23 | * @var array |
||
24 | */ |
||
25 | protected $_lang = array(); |
||
26 | |||
27 | /** |
||
28 | * @var array |
||
29 | */ |
||
30 | protected $_ns = array(); |
||
31 | |||
32 | /** |
||
33 | * Adds a new variable to lang. |
||
34 | * |
||
35 | * @param string $key Name of the variable |
||
36 | * @param string $value Value of the variable |
||
37 | * @throws \Exception |
||
38 | * @return boolean|null |
||
39 | */ |
||
40 | 4 | protected function set($key, $value) |
|
58 | |||
59 | /** |
||
60 | * Loads the language xml file. |
||
61 | * |
||
62 | * @return null |
||
63 | * @throws \Exception if it cannot find the XML file. |
||
64 | * @throws ImportException if the XML file has got a corrupted structure. |
||
65 | */ |
||
66 | 3 | public function loadLang($path) |
|
89 | |||
90 | /** |
||
91 | * Finds the best language file to use, falls back to english |
||
92 | * |
||
93 | * @param string $path |
||
94 | * @param string[] $language |
||
95 | * |
||
96 | * @return bool|string |
||
97 | */ |
||
98 | 4 | protected function findLanguage($path, $language) |
|
121 | |||
122 | /** |
||
123 | * Tests if given $key exists in lang |
||
124 | * |
||
125 | * @param string $key |
||
126 | * |
||
127 | * @return bool |
||
128 | */ |
||
129 | 2 | public function has($key) |
|
133 | |||
134 | /** |
||
135 | * Returns a key via magic method |
||
136 | * |
||
137 | * @param string $key |
||
138 | * |
||
139 | * @return null|string |
||
140 | */ |
||
141 | 1 | public function __get($key) |
|
145 | |||
146 | /** |
||
147 | * Returns the value of the specified $key in lang. |
||
148 | * |
||
149 | * @param string $key Name of the variable |
||
150 | * |
||
151 | * @return string|null Value of the specified $key |
||
152 | */ |
||
153 | 1 | public function get($key) |
|
170 | |||
171 | /** |
||
172 | * Returns the whole lang as an array. |
||
173 | * |
||
174 | * @return array Whole lang |
||
175 | */ |
||
176 | 1 | public function getAll() |
|
180 | |||
181 | /** |
||
182 | * This is used to detect the Client's browser language. |
||
183 | * |
||
184 | * @return string the shortened string of the browser's language. |
||
185 | */ |
||
186 | 3 | protected function detect_browser_language() |
|
215 | } |