1 | <?php |
||
26 | class Loader |
||
27 | { |
||
28 | /** |
||
29 | * Loader instance. |
||
30 | * |
||
31 | * @static |
||
32 | * |
||
33 | * @var Loader |
||
34 | */ |
||
35 | private static $_instance; |
||
36 | |||
37 | /** |
||
38 | * Default gettext domain to use. |
||
39 | * |
||
40 | * @var string |
||
41 | */ |
||
42 | private $default_domain = ''; |
||
43 | |||
44 | /** |
||
45 | * Configured locale. |
||
46 | * |
||
47 | * @var string |
||
48 | */ |
||
49 | private $locale = ''; |
||
50 | |||
51 | /** |
||
52 | * Loaded domains. |
||
53 | * |
||
54 | * @var array |
||
55 | */ |
||
56 | private $domains = array(); |
||
57 | |||
58 | /** |
||
59 | * Bound paths for domains. |
||
60 | * |
||
61 | * @var array |
||
62 | */ |
||
63 | private $paths = array('' => './'); |
||
64 | |||
65 | /** |
||
66 | * Returns the singleton Loader object. |
||
67 | * |
||
68 | * @return Loader object |
||
69 | */ |
||
70 | 5 | public static function getInstance() |
|
71 | { |
||
72 | 5 | if (empty(self::$_instance)) { |
|
73 | 1 | self::$_instance = new self(); |
|
74 | } |
||
75 | |||
76 | 5 | return self::$_instance; |
|
77 | } |
||
78 | |||
79 | /** |
||
80 | * Loads global localizaton functions. |
||
81 | */ |
||
82 | 2 | public static function loadFunctions() |
|
86 | |||
87 | /** |
||
88 | * Figure out all possible locale names and start with the most |
||
89 | * specific ones. I.e. for sr_CS.UTF-8@latin, look through all of |
||
90 | * sr_CS.UTF-8@latin, sr_CS@latin, sr@latin, sr_CS.UTF-8, sr_CS, sr. |
||
91 | * |
||
92 | * @param string $locale Locale code |
||
93 | * |
||
94 | * @return array list of locales to try for any POSIX-style locale specification |
||
95 | */ |
||
96 | 19 | public static function listLocales($locale) |
|
143 | |||
144 | /** |
||
145 | * Returns Translator object for domain or for default domain. |
||
146 | * |
||
147 | * @param string $domain Translation domain |
||
148 | * |
||
149 | * @return Translator |
||
150 | */ |
||
151 | public function getTranslator($domain = '') |
||
185 | |||
186 | /** |
||
187 | * Sets the path for a domain. |
||
188 | * |
||
189 | * @param string $domain Domain name |
||
190 | * @param string $path Path where to find locales |
||
191 | */ |
||
192 | public function bindtextdomain($domain, $path) |
||
196 | |||
197 | /** |
||
198 | * Sets the default domain. |
||
199 | * |
||
200 | * @param string $domain Domain name |
||
201 | */ |
||
202 | public function textdomain($domain) |
||
206 | |||
207 | /** |
||
208 | * Sets a requested locale. |
||
209 | * |
||
210 | * @param string $locale Locale name |
||
211 | * |
||
212 | * @return string Set or current locale |
||
213 | */ |
||
214 | public function setlocale($locale) |
||
226 | |||
227 | /** |
||
228 | * Detects currently configured locale. |
||
229 | * |
||
230 | * It checks: |
||
231 | * |
||
232 | * - global lang variable |
||
233 | * - environment for LC_ALL, LC_MESSAGES and LANG |
||
234 | * |
||
235 | * @return string with locale name |
||
236 | */ |
||
237 | public function detectlocale() |
||
251 | } |
||
252 |