@@ -28,67 +28,67 @@ |
||
28 | 28 | namespace OC\L10N; |
29 | 29 | |
30 | 30 | class L10NString implements \JsonSerializable { |
31 | - /** @var L10N */ |
|
32 | - protected $l10n; |
|
31 | + /** @var L10N */ |
|
32 | + protected $l10n; |
|
33 | 33 | |
34 | - /** @var string */ |
|
35 | - protected $text; |
|
34 | + /** @var string */ |
|
35 | + protected $text; |
|
36 | 36 | |
37 | - /** @var array */ |
|
38 | - protected $parameters; |
|
37 | + /** @var array */ |
|
38 | + protected $parameters; |
|
39 | 39 | |
40 | - /** @var integer */ |
|
41 | - protected $count; |
|
40 | + /** @var integer */ |
|
41 | + protected $count; |
|
42 | 42 | |
43 | - /** |
|
44 | - * @param L10N $l10n |
|
45 | - * @param string|string[] $text |
|
46 | - * @param array $parameters |
|
47 | - * @param int $count |
|
48 | - */ |
|
49 | - public function __construct(L10N $l10n, $text, array $parameters, int $count = 1) { |
|
50 | - $this->l10n = $l10n; |
|
51 | - $this->text = $text; |
|
52 | - $this->parameters = $parameters; |
|
53 | - $this->count = $count; |
|
54 | - } |
|
43 | + /** |
|
44 | + * @param L10N $l10n |
|
45 | + * @param string|string[] $text |
|
46 | + * @param array $parameters |
|
47 | + * @param int $count |
|
48 | + */ |
|
49 | + public function __construct(L10N $l10n, $text, array $parameters, int $count = 1) { |
|
50 | + $this->l10n = $l10n; |
|
51 | + $this->text = $text; |
|
52 | + $this->parameters = $parameters; |
|
53 | + $this->count = $count; |
|
54 | + } |
|
55 | 55 | |
56 | - public function __toString(): string { |
|
57 | - $translations = $this->l10n->getTranslations(); |
|
58 | - $identityTranslator = $this->l10n->getIdentityTranslator(); |
|
56 | + public function __toString(): string { |
|
57 | + $translations = $this->l10n->getTranslations(); |
|
58 | + $identityTranslator = $this->l10n->getIdentityTranslator(); |
|
59 | 59 | |
60 | - // Use the indexed version as per \Symfony\Contracts\Translation\TranslatorInterface |
|
61 | - $identity = $this->text; |
|
62 | - if (array_key_exists($this->text, $translations)) { |
|
63 | - $identity = $translations[$this->text]; |
|
64 | - } |
|
60 | + // Use the indexed version as per \Symfony\Contracts\Translation\TranslatorInterface |
|
61 | + $identity = $this->text; |
|
62 | + if (array_key_exists($this->text, $translations)) { |
|
63 | + $identity = $translations[$this->text]; |
|
64 | + } |
|
65 | 65 | |
66 | - if (is_array($identity)) { |
|
67 | - $pipeCheck = implode('', $identity); |
|
68 | - if (strpos($pipeCheck, '|') !== false) { |
|
69 | - return 'Can not use pipe character in translations'; |
|
70 | - } |
|
66 | + if (is_array($identity)) { |
|
67 | + $pipeCheck = implode('', $identity); |
|
68 | + if (strpos($pipeCheck, '|') !== false) { |
|
69 | + return 'Can not use pipe character in translations'; |
|
70 | + } |
|
71 | 71 | |
72 | - $identity = implode('|', $identity); |
|
73 | - } elseif (strpos($identity, '|') !== false) { |
|
74 | - return 'Can not use pipe character in translations'; |
|
75 | - } |
|
72 | + $identity = implode('|', $identity); |
|
73 | + } elseif (strpos($identity, '|') !== false) { |
|
74 | + return 'Can not use pipe character in translations'; |
|
75 | + } |
|
76 | 76 | |
77 | - $beforeIdentity = $identity; |
|
78 | - $identity = str_replace('%n', '%count%', $identity); |
|
77 | + $beforeIdentity = $identity; |
|
78 | + $identity = str_replace('%n', '%count%', $identity); |
|
79 | 79 | |
80 | - $parameters = []; |
|
81 | - if ($beforeIdentity !== $identity) { |
|
82 | - $parameters = ['%count%' => $this->count]; |
|
83 | - } |
|
80 | + $parameters = []; |
|
81 | + if ($beforeIdentity !== $identity) { |
|
82 | + $parameters = ['%count%' => $this->count]; |
|
83 | + } |
|
84 | 84 | |
85 | - // $count as %count% as per \Symfony\Contracts\Translation\TranslatorInterface |
|
86 | - $text = $identityTranslator->trans($identity, $parameters); |
|
85 | + // $count as %count% as per \Symfony\Contracts\Translation\TranslatorInterface |
|
86 | + $text = $identityTranslator->trans($identity, $parameters); |
|
87 | 87 | |
88 | - return vsprintf($text, $this->parameters); |
|
89 | - } |
|
88 | + return vsprintf($text, $this->parameters); |
|
89 | + } |
|
90 | 90 | |
91 | - public function jsonSerialize(): string { |
|
92 | - return $this->__toString(); |
|
93 | - } |
|
91 | + public function jsonSerialize(): string { |
|
92 | + return $this->__toString(); |
|
93 | + } |
|
94 | 94 | } |