@@ -6,9 +6,9 @@ |
||
6 | 6 | |
7 | 7 | class Localization_Scanner_StringsCollection_Warning |
8 | 8 | { |
9 | - /** |
|
10 | - * @var array |
|
11 | - */ |
|
9 | + /** |
|
10 | + * @var array |
|
11 | + */ |
|
12 | 12 | protected $data; |
13 | 13 | |
14 | 14 | public function __construct(array $data) |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | |
69 | 69 | public function addHashes(array $hashes) : Localization_Writer |
70 | 70 | { |
71 | - foreach($hashes as $hash => $text) |
|
71 | + foreach ($hashes as $hash => $text) |
|
72 | 72 | { |
73 | 73 | $this->addHash($hash, $text); |
74 | 74 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | $hashes = $this->compileHashes(); |
91 | 91 | $lines = array(); |
92 | 92 | |
93 | - foreach($hashes as $entry) |
|
93 | + foreach ($hashes as $entry) |
|
94 | 94 | { |
95 | 95 | $lines[] = sprintf( |
96 | 96 | '%s= "%s"', |
@@ -106,16 +106,16 @@ discard block |
||
106 | 106 | |
107 | 107 | private function renderHead() : string |
108 | 108 | { |
109 | - $title = strtoupper($this->fileType).' TRANSLATION FILE FOR ' . strtoupper($this->locale->getLabel()); |
|
109 | + $title = strtoupper($this->fileType).' TRANSLATION FILE FOR '.strtoupper($this->locale->getLabel()); |
|
110 | 110 | |
111 | 111 | $lines = array(); |
112 | 112 | |
113 | 113 | $lines[] = '; -------------------------------------------------------'; |
114 | - $lines[] = '; '. $title; |
|
114 | + $lines[] = '; '.$title; |
|
115 | 115 | $lines[] = '; -------------------------------------------------------'; |
116 | 116 | $lines[] = '; '; |
117 | 117 | |
118 | - if($this->editable) |
|
118 | + if ($this->editable) |
|
119 | 119 | { |
120 | 120 | $lines[] = '; You may edit text directly in this file under the following conditions:'; |
121 | 121 | $lines[] = '; '; |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | { |
138 | 138 | $hashes = array(); |
139 | 139 | |
140 | - foreach($this->hashes as $hash => $text) |
|
140 | + foreach ($this->hashes as $hash => $text) |
|
141 | 141 | { |
142 | 142 | $hashes[] = array( |
143 | 143 | 'hash' => $hash, |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | { |
165 | 165 | $result = strnatcasecmp($a['text'], $b['text']); |
166 | 166 | |
167 | - if($result === 0) |
|
167 | + if ($result === 0) |
|
168 | 168 | { |
169 | 169 | return strnatcmp($a['hash'], $b['hash']); |
170 | 170 | } |
@@ -121,8 +121,7 @@ |
||
121 | 121 | $lines[] = '; '; |
122 | 122 | $lines[] = '; 1) Do not to modify the keys (left hand side of the = sign)'; |
123 | 123 | $lines[] = '; 2) Save the file as UTF-8 without BOM'; |
124 | - } |
|
125 | - else |
|
124 | + } else |
|
126 | 125 | { |
127 | 126 | $lines[] = '; Do NOT edit this file directly! It depends on the main translation file'; |
128 | 127 | $lines[] = '; and any changes will be lost. Edit the main file instead.'; |
@@ -20,29 +20,29 @@ discard block |
||
20 | 20 | */ |
21 | 21 | class Localization_Writer |
22 | 22 | { |
23 | - /** |
|
24 | - * @var boolean |
|
25 | - */ |
|
23 | + /** |
|
24 | + * @var boolean |
|
25 | + */ |
|
26 | 26 | private $editable = false; |
27 | 27 | |
28 | - /** |
|
29 | - * @var array<string,string> |
|
30 | - */ |
|
28 | + /** |
|
29 | + * @var array<string,string> |
|
30 | + */ |
|
31 | 31 | private $hashes = array(); |
32 | 32 | |
33 | - /** |
|
34 | - * @var Localization_Locale |
|
35 | - */ |
|
33 | + /** |
|
34 | + * @var Localization_Locale |
|
35 | + */ |
|
36 | 36 | private $locale; |
37 | 37 | |
38 | - /** |
|
39 | - * @var string |
|
40 | - */ |
|
38 | + /** |
|
39 | + * @var string |
|
40 | + */ |
|
41 | 41 | private $fileType; |
42 | 42 | |
43 | - /** |
|
44 | - * @var string |
|
45 | - */ |
|
43 | + /** |
|
44 | + * @var string |
|
45 | + */ |
|
46 | 46 | private $filePath; |
47 | 47 | |
48 | 48 | public function __construct(Localization_Locale $locale, string $fileType, string $filePath) |
@@ -150,16 +150,16 @@ discard block |
||
150 | 150 | return $hashes; |
151 | 151 | } |
152 | 152 | |
153 | - /** |
|
154 | - * Sort the strings to ensure they always appear in the same order: |
|
155 | - * first by text, and same strings by their hashes. This is important |
|
156 | - * for strings that have the same translation to avoid them changing |
|
157 | - * order between sorts. |
|
158 | - * |
|
159 | - * @param array $a |
|
160 | - * @param array $b |
|
161 | - * @return int |
|
162 | - */ |
|
153 | + /** |
|
154 | + * Sort the strings to ensure they always appear in the same order: |
|
155 | + * first by text, and same strings by their hashes. This is important |
|
156 | + * for strings that have the same translation to avoid them changing |
|
157 | + * order between sorts. |
|
158 | + * |
|
159 | + * @param array $a |
|
160 | + * @param array $b |
|
161 | + * @return int |
|
162 | + */ |
|
163 | 163 | public function callback_sortStrings(array $a, array $b) : int |
164 | 164 | { |
165 | 165 | $result = strnatcasecmp($a['text'], $b['text']); |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | |
107 | 107 | $texts = $language->getTexts(); |
108 | 108 | |
109 | - foreach($texts as $text) |
|
109 | + foreach ($texts as $text) |
|
110 | 110 | { |
111 | 111 | $this->collection->addFromFile( |
112 | 112 | $this->getID(), |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | |
119 | 119 | $warnings = $language->getWarnings(); |
120 | 120 | |
121 | - foreach($warnings as $warning) { |
|
121 | + foreach ($warnings as $warning) { |
|
122 | 122 | $this->collection->addWarning($warning); |
123 | 123 | } |
124 | 124 | } |
@@ -145,9 +145,9 @@ discard block |
||
145 | 145 | $amount = 0; |
146 | 146 | |
147 | 147 | $hashes = $this->getHashes($scanner); |
148 | - foreach($hashes as $hash) { |
|
148 | + foreach ($hashes as $hash) { |
|
149 | 149 | $text = $translator->getHashTranslation($hash->getHash()); |
150 | - if(empty($text)) { |
|
150 | + if (empty($text)) { |
|
151 | 151 | $amount++; |
152 | 152 | } |
153 | 153 | } |
@@ -6,39 +6,39 @@ |
||
6 | 6 | |
7 | 7 | abstract class Localization_Source |
8 | 8 | { |
9 | - /** |
|
10 | - * Human-readable label for the source. |
|
11 | - * @var string |
|
12 | - */ |
|
9 | + /** |
|
10 | + * Human-readable label for the source. |
|
11 | + * @var string |
|
12 | + */ |
|
13 | 13 | protected $label; |
14 | 14 | |
15 | - /** |
|
16 | - * Human-readable group name to categorize the source. |
|
17 | - * @var string |
|
18 | - */ |
|
15 | + /** |
|
16 | + * Human-readable group name to categorize the source. |
|
17 | + * @var string |
|
18 | + */ |
|
19 | 19 | protected $group; |
20 | 20 | |
21 | - /** |
|
22 | - * The folder in which the localization files are stored |
|
23 | - * @var string |
|
24 | - */ |
|
21 | + /** |
|
22 | + * The folder in which the localization files are stored |
|
23 | + * @var string |
|
24 | + */ |
|
25 | 25 | protected $storageFolder; |
26 | 26 | |
27 | - /** |
|
28 | - * @var string |
|
29 | - */ |
|
27 | + /** |
|
28 | + * @var string |
|
29 | + */ |
|
30 | 30 | protected $alias; |
31 | 31 | |
32 | - /** |
|
33 | - * Available during scanning. |
|
34 | - * @var Localization_Scanner_StringsCollection|NULL |
|
35 | - */ |
|
32 | + /** |
|
33 | + * Available during scanning. |
|
34 | + * @var Localization_Scanner_StringsCollection|NULL |
|
35 | + */ |
|
36 | 36 | protected $collection; |
37 | 37 | |
38 | - /** |
|
39 | - * Available during scanning. |
|
40 | - * @var Localization_Parser|NULL |
|
41 | - */ |
|
38 | + /** |
|
39 | + * Available during scanning. |
|
40 | + * @var Localization_Parser|NULL |
|
41 | + */ |
|
42 | 42 | protected $parser; |
43 | 43 | |
44 | 44 | public function __construct(string $alias, string $label, string $group, string $storageFolder) |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | { |
104 | 104 | $ext = FileHelper::getExtension($path); |
105 | 105 | |
106 | - if($this->isExtensionSupported($ext)) { |
|
106 | + if ($this->isExtensionSupported($ext)) { |
|
107 | 107 | return; |
108 | 108 | } |
109 | 109 | |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | { |
127 | 127 | $values = $this->getLanguageIDs(); |
128 | 128 | |
129 | - if(in_array($languageID, $values)) { |
|
129 | + if (in_array($languageID, $values)) { |
|
130 | 130 | return; |
131 | 131 | } |
132 | 132 | |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | { |
171 | 171 | $this->requireValidLanguageID($languageID); |
172 | 172 | |
173 | - if(!isset($this->languageParsers[$languageID])) |
|
173 | + if (!isset($this->languageParsers[$languageID])) |
|
174 | 174 | { |
175 | 175 | $this->languageParsers[$languageID] = $this->createLanguageInstance($languageID); |
176 | 176 | } |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | |
191 | 191 | $object = new $class($this); |
192 | 192 | |
193 | - if($object instanceof Localization_Parser_Language) |
|
193 | + if ($object instanceof Localization_Parser_Language) |
|
194 | 194 | { |
195 | 195 | return $object; |
196 | 196 | } |
@@ -30,14 +30,14 @@ discard block |
||
30 | 30 | const ERROR_UNSUPPORTED_FILE_EXTENSION = 40602; |
31 | 31 | const ERROR_INVALID_LANGUAGE_CLASS = 40603; |
32 | 32 | |
33 | - /** |
|
34 | - * @var Localization_Scanner |
|
35 | - */ |
|
33 | + /** |
|
34 | + * @var Localization_Scanner |
|
35 | + */ |
|
36 | 36 | protected $scanner; |
37 | 37 | |
38 | - /** |
|
39 | - * @var Localization_Scanner_StringsCollection |
|
40 | - */ |
|
38 | + /** |
|
39 | + * @var Localization_Scanner_StringsCollection |
|
40 | + */ |
|
41 | 41 | protected $collection; |
42 | 42 | |
43 | 43 | /** |
@@ -54,15 +54,15 @@ discard block |
||
54 | 54 | $this->collection = $scanner->getCollection(); |
55 | 55 | } |
56 | 56 | |
57 | - /** |
|
58 | - * Parses a source file. Must have a valid supported file extension. |
|
59 | - * |
|
60 | - * @param string $path |
|
61 | - * @return Localization_Parser_Language |
|
62 | - * @throws Localization_Exception |
|
63 | - * |
|
64 | - * @see Localization_Parser::ERROR_UNSUPPORTED_FILE_EXTENSION |
|
65 | - */ |
|
57 | + /** |
|
58 | + * Parses a source file. Must have a valid supported file extension. |
|
59 | + * |
|
60 | + * @param string $path |
|
61 | + * @return Localization_Parser_Language |
|
62 | + * @throws Localization_Exception |
|
63 | + * |
|
64 | + * @see Localization_Parser::ERROR_UNSUPPORTED_FILE_EXTENSION |
|
65 | + */ |
|
66 | 66 | public function parseFile(string $path) : Localization_Parser_Language |
67 | 67 | { |
68 | 68 | $this->requireValidFile($path); |
@@ -76,16 +76,16 @@ discard block |
||
76 | 76 | return $language; |
77 | 77 | } |
78 | 78 | |
79 | - /** |
|
80 | - * Parses the string for the specified language. |
|
81 | - * |
|
82 | - * @param string $languageID |
|
83 | - * @param string $code |
|
84 | - * @return Localization_Parser_Language |
|
85 | - * @throws Localization_Exception |
|
86 | - * |
|
87 | - * @see Localization_Parser::ERROR_INVALID_LANGUAGE_ID |
|
88 | - */ |
|
79 | + /** |
|
80 | + * Parses the string for the specified language. |
|
81 | + * |
|
82 | + * @param string $languageID |
|
83 | + * @param string $code |
|
84 | + * @return Localization_Parser_Language |
|
85 | + * @throws Localization_Exception |
|
86 | + * |
|
87 | + * @see Localization_Parser::ERROR_INVALID_LANGUAGE_ID |
|
88 | + */ |
|
89 | 89 | public function parseString(string $languageID, string $code) : Localization_Parser_Language |
90 | 90 | { |
91 | 91 | $this->requireValidLanguageID($languageID); |
@@ -144,18 +144,18 @@ discard block |
||
144 | 144 | ); |
145 | 145 | } |
146 | 146 | |
147 | - /** |
|
148 | - * Retrieves a list of all language IDs that are supported. |
|
149 | - * @return string[] IDs list like "PHP", "Javascript" |
|
150 | - */ |
|
147 | + /** |
|
148 | + * Retrieves a list of all language IDs that are supported. |
|
149 | + * @return string[] IDs list like "PHP", "Javascript" |
|
150 | + */ |
|
151 | 151 | public function getLanguageIDs() : array |
152 | 152 | { |
153 | 153 | return array_values($this->languageMappings); |
154 | 154 | } |
155 | 155 | |
156 | - /** |
|
157 | - * @var array<string,Localization_Parser_Language> |
|
158 | - */ |
|
156 | + /** |
|
157 | + * @var array<string,Localization_Parser_Language> |
|
158 | + */ |
|
159 | 159 | protected $languageParsers = array(); |
160 | 160 | |
161 | 161 | /** |
@@ -209,12 +209,12 @@ discard block |
||
209 | 209 | ); |
210 | 210 | } |
211 | 211 | |
212 | - /** |
|
213 | - * Whether the specified file extension is supported. |
|
214 | - * |
|
215 | - * @param string $ext |
|
216 | - * @return bool |
|
217 | - */ |
|
212 | + /** |
|
213 | + * Whether the specified file extension is supported. |
|
214 | + * |
|
215 | + * @param string $ext |
|
216 | + * @return bool |
|
217 | + */ |
|
218 | 218 | public function isExtensionSupported(string $ext) : bool |
219 | 219 | { |
220 | 220 | $ext = strtolower($ext); |
@@ -29,7 +29,7 @@ |
||
29 | 29 | */ |
30 | 30 | private $hash; |
31 | 31 | |
32 | - public function __construct(string $text, int $line, string $explanation='') |
|
32 | + public function __construct(string $text, int $line, string $explanation = '') |
|
33 | 33 | { |
34 | 34 | $this->text = $text; |
35 | 35 | $this->line = $line; |
@@ -12,8 +12,8 @@ |
||
12 | 12 | const SERIALIZED_PROPERTIES = 'properties'; |
13 | 13 | |
14 | 14 | /** |
15 | - * @var Localization_Scanner_StringsCollection |
|
16 | - */ |
|
15 | + * @var Localization_Scanner_StringsCollection |
|
16 | + */ |
|
17 | 17 | protected $collection; |
18 | 18 | |
19 | 19 | /** |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | |
88 | 88 | public function getProperty(string $name) : ?string |
89 | 89 | { |
90 | - if(isset($this->properties[$name])) { |
|
90 | + if (isset($this->properties[$name])) { |
|
91 | 91 | return $this->properties[$name]; |
92 | 92 | } |
93 | 93 | |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | Text::fromArray($array[self::SERIALIZED_TEXT]) |
142 | 142 | ); |
143 | 143 | |
144 | - foreach($array[self::SERIALIZED_PROPERTIES] as $name => $value) { |
|
144 | + foreach ($array[self::SERIALIZED_PROPERTIES] as $name => $value) { |
|
145 | 145 | $string->setProperty($name, $value); |
146 | 146 | } |
147 | 147 |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | { |
51 | 51 | $entries = array(); |
52 | 52 | |
53 | - foreach($this->strings as $string) { |
|
53 | + foreach ($this->strings as $string) { |
|
54 | 54 | $entries[] = $string->toArray(); |
55 | 55 | } |
56 | 56 | |
@@ -70,8 +70,8 @@ discard block |
||
70 | 70 | { |
71 | 71 | $amount = 0; |
72 | 72 | |
73 | - foreach($this->strings as $string) { |
|
74 | - if($string->isFile()) { |
|
73 | + foreach ($this->strings as $string) { |
|
74 | + if ($string->isFile()) { |
|
75 | 75 | $amount++; |
76 | 76 | } |
77 | 77 | } |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | |
87 | 87 | public function hasLanguageType(string $type) : bool |
88 | 88 | { |
89 | - foreach($this->strings as $string) { |
|
90 | - if($string->getLanguageType() == $type) { |
|
89 | + foreach ($this->strings as $string) { |
|
90 | + if ($string->getLanguageType() == $type) { |
|
91 | 91 | return true; |
92 | 92 | } |
93 | 93 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | |
98 | 98 | public function getText() : ?Text |
99 | 99 | { |
100 | - if(isset($this->strings[0])) { |
|
100 | + if (isset($this->strings[0])) { |
|
101 | 101 | return $this->strings[0]->getText(); |
102 | 102 | } |
103 | 103 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | $translator = Localization::getTranslator(); |
130 | 130 | $text = $translator->getHashTranslation($this->getHash()); |
131 | 131 | |
132 | - if($text !== null) { |
|
132 | + if ($text !== null) { |
|
133 | 133 | return $text; |
134 | 134 | } |
135 | 135 | |
@@ -144,14 +144,14 @@ discard block |
||
144 | 144 | { |
145 | 145 | $files = array(); |
146 | 146 | |
147 | - foreach($this->strings as $string) |
|
147 | + foreach ($this->strings as $string) |
|
148 | 148 | { |
149 | - if(!$string->isFile()) { |
|
149 | + if (!$string->isFile()) { |
|
150 | 150 | continue; |
151 | 151 | } |
152 | 152 | |
153 | 153 | $file = $string->getSourceFile(); |
154 | - if(!in_array($file, $files)) { |
|
154 | + if (!in_array($file, $files)) { |
|
155 | 155 | $files[] = $file; |
156 | 156 | } |
157 | 157 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | $files = $this->getFiles(); |
171 | 171 | $result = array(); |
172 | 172 | |
173 | - foreach($files as $path) { |
|
173 | + foreach ($files as $path) { |
|
174 | 174 | $result[] = basename($path); |
175 | 175 | } |
176 | 176 |
@@ -15,19 +15,19 @@ discard block |
||
15 | 15 | */ |
16 | 16 | class Localization_Scanner_StringHash |
17 | 17 | { |
18 | - /** |
|
19 | - * @var Localization_Scanner_StringsCollection |
|
20 | - */ |
|
18 | + /** |
|
19 | + * @var Localization_Scanner_StringsCollection |
|
20 | + */ |
|
21 | 21 | protected $collection; |
22 | 22 | |
23 | - /** |
|
24 | - * @var string |
|
25 | - */ |
|
23 | + /** |
|
24 | + * @var string |
|
25 | + */ |
|
26 | 26 | protected $hash; |
27 | 27 | |
28 | - /** |
|
29 | - * @var Localization_Scanner_StringInfo[] |
|
30 | - */ |
|
28 | + /** |
|
29 | + * @var Localization_Scanner_StringInfo[] |
|
30 | + */ |
|
31 | 31 | protected $strings = array(); |
32 | 32 | |
33 | 33 | /** |
@@ -60,10 +60,10 @@ discard block |
||
60 | 60 | return $entries; |
61 | 61 | } |
62 | 62 | |
63 | - /** |
|
64 | - * Retrieves all individual string locations where this text was found. |
|
65 | - * @return Localization_Scanner_StringInfo[] |
|
66 | - */ |
|
63 | + /** |
|
64 | + * Retrieves all individual string locations where this text was found. |
|
65 | + * @return Localization_Scanner_StringInfo[] |
|
66 | + */ |
|
67 | 67 | public function getStrings() : array |
68 | 68 | { |
69 | 69 | return $this->strings; |
@@ -123,10 +123,10 @@ discard block |
||
123 | 123 | return count($this->strings); |
124 | 124 | } |
125 | 125 | |
126 | - /** |
|
127 | - * Retrieves the translated text, if any. |
|
128 | - * @return string |
|
129 | - */ |
|
126 | + /** |
|
127 | + * Retrieves the translated text, if any. |
|
128 | + * @return string |
|
129 | + */ |
|
130 | 130 | public function getTranslatedText() : string |
131 | 131 | { |
132 | 132 | $translator = Localization::getTranslator(); |
@@ -139,10 +139,10 @@ discard block |
||
139 | 139 | return ''; |
140 | 140 | } |
141 | 141 | |
142 | - /** |
|
143 | - * Retrieves a list of all file names, with relative paths. |
|
144 | - * @return string[] |
|
145 | - */ |
|
142 | + /** |
|
143 | + * Retrieves a list of all file names, with relative paths. |
|
144 | + * @return string[] |
|
145 | + */ |
|
146 | 146 | public function getFiles() : array |
147 | 147 | { |
148 | 148 | $files = array(); |
@@ -164,10 +164,10 @@ discard block |
||
164 | 164 | return $files; |
165 | 165 | } |
166 | 166 | |
167 | - /** |
|
168 | - * Retrieves a list of all file names this string is used in. |
|
169 | - * @return string[] |
|
170 | - */ |
|
167 | + /** |
|
168 | + * Retrieves a list of all file names this string is used in. |
|
169 | + * @return string[] |
|
170 | + */ |
|
171 | 171 | public function getFileNames() : array |
172 | 172 | { |
173 | 173 | $files = $this->getFiles(); |
@@ -182,13 +182,13 @@ discard block |
||
182 | 182 | return array_unique($result); |
183 | 183 | } |
184 | 184 | |
185 | - /** |
|
186 | - * Retrieves a text comprised of all strings that are relevant |
|
187 | - * for a full text search, imploded together. Used in the search |
|
188 | - * function to find matching strings. |
|
189 | - * |
|
190 | - * @return string |
|
191 | - */ |
|
185 | + /** |
|
186 | + * Retrieves a text comprised of all strings that are relevant |
|
187 | + * for a full text search, imploded together. Used in the search |
|
188 | + * function to find matching strings. |
|
189 | + * |
|
190 | + * @return string |
|
191 | + */ |
|
192 | 192 | public function getSearchString() : string |
193 | 193 | { |
194 | 194 | $parts = array($this->getTranslatedText(), $this->getText()->getText()); |
@@ -54,7 +54,7 @@ |
||
54 | 54 | */ |
55 | 55 | public function getFloat() : float |
56 | 56 | { |
57 | - return floatval($this->number . '.' . $this->decimals); |
|
57 | + return floatval($this->number.'.'.$this->decimals); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -57,8 +57,8 @@ discard block |
||
57 | 57 | protected $reverseStrings = array(); |
58 | 58 | |
59 | 59 | /** |
60 | - * @var Localization_Source[] |
|
61 | - */ |
|
60 | + * @var Localization_Source[] |
|
61 | + */ |
|
62 | 62 | private $sources = array(); |
63 | 63 | |
64 | 64 | /** |
@@ -191,14 +191,14 @@ discard block |
||
191 | 191 | ); |
192 | 192 | } |
193 | 193 | |
194 | - /** |
|
195 | - * Retrieves all available strings for the specified locale, |
|
196 | - * as hash => text value pairs. |
|
197 | - * |
|
198 | - * @param Localization_Locale $locale |
|
199 | - * @throws Localization_Exception |
|
200 | - * @return string[] |
|
201 | - */ |
|
194 | + /** |
|
195 | + * Retrieves all available strings for the specified locale, |
|
196 | + * as hash => text value pairs. |
|
197 | + * |
|
198 | + * @param Localization_Locale $locale |
|
199 | + * @throws Localization_Exception |
|
200 | + * @return string[] |
|
201 | + */ |
|
202 | 202 | public function getStrings(Localization_Locale $locale) : array |
203 | 203 | { |
204 | 204 | $this->load($locale); |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public function addSources(array $sources) : void |
81 | 81 | { |
82 | - foreach($sources as $source) { |
|
82 | + foreach ($sources as $source) { |
|
83 | 83 | $this->addSource($source); |
84 | 84 | } |
85 | 85 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | $this->strings[$localeName] = array(); |
125 | 125 | } |
126 | 126 | |
127 | - foreach($this->sources as $source) |
|
127 | + foreach ($this->sources as $source) |
|
128 | 128 | { |
129 | 129 | $file = $this->resolveStorageFile($locale, $source); |
130 | 130 | if (!file_exists($file)) { |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | |
134 | 134 | $data = parse_ini_file($file, false); |
135 | 135 | |
136 | - if($data === false) |
|
136 | + if ($data === false) |
|
137 | 137 | { |
138 | 138 | throw new Localization_Exception( |
139 | 139 | 'Malformatted localization file', |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | |
206 | 206 | $name = $locale->getName(); |
207 | 207 | |
208 | - if(isset($this->strings[$name])) { |
|
208 | + if (isset($this->strings[$name])) { |
|
209 | 209 | return $this->strings[$name]; |
210 | 210 | } |
211 | 211 | |
@@ -240,11 +240,11 @@ discard block |
||
240 | 240 | * @param Localization_Locale $locale |
241 | 241 | * @param boolean $editable |
242 | 242 | */ |
243 | - protected function renderStringsFile(string $type, Localization_Source $source, array $hashes, string $file, Localization_Locale $locale, bool $editable=true) : void |
|
243 | + protected function renderStringsFile(string $type, Localization_Source $source, array $hashes, string $file, Localization_Locale $locale, bool $editable = true) : void |
|
244 | 244 | { |
245 | 245 | $writer = new Localization_Writer($locale, $type, $file); |
246 | 246 | |
247 | - if($editable) |
|
247 | + if ($editable) |
|
248 | 248 | { |
249 | 249 | $writer->makeEditable(); |
250 | 250 | } |
@@ -253,14 +253,14 @@ discard block |
||
253 | 253 | |
254 | 254 | foreach ($hashes as $hash) |
255 | 255 | { |
256 | - if(!$hash->hasSourceID($sourceID)) { |
|
256 | + if (!$hash->hasSourceID($sourceID)) { |
|
257 | 257 | continue; |
258 | 258 | } |
259 | 259 | |
260 | 260 | $text = $this->getHashTranslation($hash->getHash(), $locale); |
261 | 261 | |
262 | 262 | // skip any empty strings |
263 | - if($text === null || trim($text) == '') { |
|
263 | + if ($text === null || trim($text) == '') { |
|
264 | 264 | continue; |
265 | 265 | } |
266 | 266 | |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | { |
339 | 339 | // to avoid re-creating the hash for the same texts over and over, |
340 | 340 | // we keep track of the hashes we created, and re-use them. |
341 | - if(isset($this->reverseStrings[$text])) { |
|
341 | + if (isset($this->reverseStrings[$text])) { |
|
342 | 342 | $hash = $this->reverseStrings[$text]; |
343 | 343 | } else { |
344 | 344 | $hash = md5($text); |
@@ -403,15 +403,15 @@ discard block |
||
403 | 403 | * @param Localization_Locale|null $locale |
404 | 404 | * @return string|NULL |
405 | 405 | */ |
406 | - public function getHashTranslation(string $hash, ?Localization_Locale $locale=null) : ?string |
|
406 | + public function getHashTranslation(string $hash, ?Localization_Locale $locale = null) : ?string |
|
407 | 407 | { |
408 | - if(!$locale) { |
|
408 | + if (!$locale) { |
|
409 | 409 | $locale = $this->targetLocale; |
410 | 410 | } |
411 | 411 | |
412 | 412 | $localeName = $locale->getName(); |
413 | 413 | |
414 | - if(isset($this->strings[$localeName]) && isset($this->strings[$localeName][$hash])) { |
|
414 | + if (isset($this->strings[$localeName]) && isset($this->strings[$localeName][$hash])) { |
|
415 | 415 | return $this->strings[$localeName][$hash]; |
416 | 416 | } |
417 | 417 | |
@@ -429,10 +429,10 @@ discard block |
||
429 | 429 | { |
430 | 430 | $result = array(); |
431 | 431 | |
432 | - foreach($this->sources as $source) |
|
432 | + foreach ($this->sources as $source) |
|
433 | 433 | { |
434 | 434 | $localeFile = self::getClientStorageFile($locale, $source); |
435 | - if(!file_exists($localeFile)) { |
|
435 | + if (!file_exists($localeFile)) { |
|
436 | 436 | continue; |
437 | 437 | } |
438 | 438 |