|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, https://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Metaways Infosystems GmbH, 2012 |
|
6
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2021 |
|
7
|
|
|
* @package MW |
|
8
|
|
|
* @subpackage Translation |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
namespace Aimeos\MW\Translation\Decorator; |
|
13
|
|
|
|
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Base class for all translator decorators. |
|
17
|
|
|
* |
|
18
|
|
|
* @package MW |
|
19
|
|
|
* @subpackage Translation |
|
20
|
|
|
*/ |
|
21
|
|
|
abstract class Base |
|
22
|
|
|
extends \Aimeos\MW\Translation\Base |
|
23
|
|
|
implements \Aimeos\MW\Translation\Decorator\Iface |
|
24
|
|
|
{ |
|
25
|
|
|
private $object; |
|
26
|
|
|
|
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Initializes the decorator. |
|
30
|
|
|
* |
|
31
|
|
|
* @param \Aimeos\MW\Translation\Iface $object Translation object or decorator |
|
32
|
|
|
*/ |
|
33
|
|
|
public function __construct( \Aimeos\MW\Translation\Iface $object ) |
|
34
|
|
|
{ |
|
35
|
|
|
$this->object = $object; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Returns the translated string. |
|
41
|
|
|
* |
|
42
|
|
|
* @param string $domain Translation domain |
|
43
|
|
|
* @param string $string String to be translated |
|
44
|
|
|
* @return string The translated string |
|
45
|
|
|
*/ |
|
46
|
|
|
public function dt( string $domain, string $string ) : string |
|
47
|
|
|
{ |
|
48
|
|
|
return $this->object->dt( $domain, $string ); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Returns the translated string by the given plural and quantity. |
|
54
|
|
|
* |
|
55
|
|
|
* @param string $domain Translation domain |
|
56
|
|
|
* @param string $singular String in singular form |
|
57
|
|
|
* @param string $plural String in plural form |
|
58
|
|
|
* @param int $number Quantity to chose the correct plural form for languages with plural forms |
|
59
|
|
|
* @return string Returns the translated singular or plural form of the string depending on the given number. |
|
60
|
|
|
*/ |
|
61
|
|
|
public function dn( string $domain, string $singular, string $plural, int $number ) : string |
|
62
|
|
|
{ |
|
63
|
|
|
return $this->object->dn( $domain, $singular, $plural, $number ); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* Returns all locale string of the given domain. |
|
69
|
|
|
* |
|
70
|
|
|
* @param string $domain Translation domain |
|
71
|
|
|
* @return array Associative list with original string as key and translation |
|
72
|
|
|
* as value or an associative list with index => translation as value if |
|
73
|
|
|
* plural forms are available |
|
74
|
|
|
*/ |
|
75
|
|
|
public function all( string $domain ) : array |
|
76
|
|
|
{ |
|
77
|
|
|
return $this->object->all( $domain ); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* Returns the current locale string. |
|
83
|
|
|
* |
|
84
|
|
|
* @return string ISO locale string |
|
85
|
|
|
*/ |
|
86
|
|
|
public function getLocale() : string |
|
87
|
|
|
{ |
|
88
|
|
|
return $this->object->getLocale(); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* Returns the wrapped translation object. |
|
94
|
|
|
* |
|
95
|
|
|
* @return \Aimeos\MW\Translation\Iface Translation object |
|
96
|
|
|
*/ |
|
97
|
|
|
protected function object() : \Aimeos\MW\Translation\Iface |
|
98
|
|
|
{ |
|
99
|
|
|
return $this->object; |
|
100
|
|
|
} |
|
101
|
|
|
} |
|
102
|
|
|
|