1 <?php
2
3 4 5 6 7 8 9 10
11
12 namespace ICanBoogie\I18n\Translator;
13
14 use ICanBoogie\Object;
15
16 17 18 19
20 class Proxi extends Object
21 {
22 protected $options = array();
23
24 public function __construct(array $options=array())
25 {
26 $this->options = $options;
27
28 if (isset($this->options['scope']))
29 {
30 $this->scope = $this->options['scope'];
31 }
32 }
33
34 protected function set_scope($scope)
35 {
36 if (is_array($scope))
37 {
38 $scope = implode('.', $scope);
39 }
40
41 $this->options['scope'] = $scope;
42 }
43
44 protected function set_language($language)
45 {
46 $this->options['language'] = $language;
47 }
48
49 protected function set_default($default)
50 {
51 $this->options['default'] = $default;
52 }
53
54 public function __invoke($str, array $args=array(), array $options=array())
55 {
56 $options += $this->options;
57
58 if (isset($options['scope']) && isset($this->options['scope']))
59 {
60 $scope = $options['scope'];
61
62 if (is_array($scope))
63 {
64 $scope = implode('.', $scope);
65 }
66
67 if ($scope{0} == '.')
68 {
69 $options['scope'] = $this->options['scope'] . $scope;
70 }
71 }
72
73 return \ICanBoogie\I18n\t($str, $args, $options);
74 }
75 }