|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Ubiquity\translation; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Injectable translator (to use with di) |
|
7
|
|
|
* @author jcheron <[email protected]> |
|
8
|
|
|
* @version 1.0.1 |
|
9
|
|
|
*/ |
|
10
|
|
|
class Translator { |
|
11
|
|
|
private $manager; |
|
12
|
|
|
|
|
13
|
|
|
public function __construct($locale="en_EN",$fallbackLocale=null,$rootDir=null){ |
|
14
|
|
|
$this->manager=new TranslatorManager(); |
|
15
|
|
|
$this->manager->start($locale,$fallbackLocale,$rootDir); |
|
16
|
|
|
} |
|
17
|
|
|
|
|
18
|
|
|
public function setLocale($locale){ |
|
19
|
|
|
$this->manager->setLocale($locale); |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
public function setRootDir($rootDir=null){ |
|
23
|
|
|
$this->manager->setRootDir($rootDir); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
public function getLocale(){ |
|
27
|
|
|
return $this->manager->getLocale(); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
public function trans($id, array $parameters = array(), $domain = null, $locale = null){ |
|
31
|
|
|
return $this->manager->trans($id,$parameters,$domain,$locale); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
public function getCatalogue(&$locale = null){ |
|
35
|
|
|
return $this->manager->getCatalogue($locale); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
public function loadCatalogue($locale = null){ |
|
39
|
|
|
$this->manager->loadCatalogue($locale); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @return mixed |
|
44
|
|
|
*/ |
|
45
|
|
|
public function getFallbackLocale() { |
|
46
|
|
|
return $this->manager->getFallbackLocale(); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @param mixed $fallbackLocale |
|
51
|
|
|
*/ |
|
52
|
|
|
public function setFallbackLocale($fallbackLocale) { |
|
53
|
|
|
$this->manager->setFallbackLocale($fallbackLocale); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
public function clearCache(){ |
|
57
|
|
|
$this->manager->clearCache(); |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
|