@@ -35,23 +35,23 @@ discard block |
||
| 35 | 35 | $this->editor = $editor; |
| 36 | 36 | $this->request = $editor->getRequest(); |
| 37 | 37 | |
| 38 | - foreach($this->vars as $var => $name) { |
|
| 38 | + foreach ($this->vars as $var => $name) { |
|
| 39 | 39 | $this->vars[$var] = $this->editor->getVarName($var); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - if(!isset($_SESSION[$this->sessionName])) { |
|
| 42 | + if (!isset($_SESSION[$this->sessionName])) { |
|
| 43 | 43 | $_SESSION[$this->sessionName] = array(); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - if($this->request->getBool($this->vars['resetfilter'])) |
|
| 46 | + if ($this->request->getBool($this->vars['resetfilter'])) |
|
| 47 | 47 | { |
| 48 | 48 | $defaults = $this->getDefaultValues(); |
| 49 | 49 | |
| 50 | - foreach($defaults as $name => $val) { |
|
| 50 | + foreach ($defaults as $name => $val) { |
|
| 51 | 51 | $this->setValue($name, $val); |
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | - else if($this->request->getBool($this->vars['filter'])) |
|
| 54 | + else if ($this->request->getBool($this->vars['filter'])) |
|
| 55 | 55 | { |
| 56 | 56 | $this->parseSearchTerms($this->request->getParam($this->vars['search'])); |
| 57 | 57 | |
@@ -86,12 +86,12 @@ discard block |
||
| 86 | 86 | |
| 87 | 87 | protected function getValue(string $filterName) : string |
| 88 | 88 | { |
| 89 | - if(isset($_SESSION[$this->sessionName][$filterName])) { |
|
| 89 | + if (isset($_SESSION[$this->sessionName][$filterName])) { |
|
| 90 | 90 | return $_SESSION[$this->sessionName][$filterName]; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | $defaults = $this->getDefaultValues(); |
| 94 | - if(isset($defaults[$filterName])) { |
|
| 94 | + if (isset($defaults[$filterName])) { |
|
| 95 | 95 | return $defaults[$filterName]; |
| 96 | 96 | } |
| 97 | 97 | |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | |
| 104 | 104 | protected function parseSearchTerms(string $searchString) |
| 105 | 105 | { |
| 106 | - if(empty($searchString)) |
|
| 106 | + if (empty($searchString)) |
|
| 107 | 107 | { |
| 108 | 108 | $this->searchTerms = array(); |
| 109 | 109 | $this->searchString = ''; |
@@ -117,8 +117,8 @@ discard block |
||
| 117 | 117 | $terms = array_map('trim', $terms); |
| 118 | 118 | |
| 119 | 119 | $keep = array(); |
| 120 | - foreach($terms as $term) { |
|
| 121 | - if(!empty($term)) { |
|
| 120 | + foreach ($terms as $term) { |
|
| 121 | + if (!empty($term)) { |
|
| 122 | 122 | $keep[] = $term; |
| 123 | 123 | } |
| 124 | 124 | } |
@@ -129,28 +129,28 @@ discard block |
||
| 129 | 129 | |
| 130 | 130 | public function isStringMatch(Localization_Scanner_StringHash $string) |
| 131 | 131 | { |
| 132 | - if(!empty($this->searchTerms)) |
|
| 132 | + if (!empty($this->searchTerms)) |
|
| 133 | 133 | { |
| 134 | 134 | $haystack = $string->getSearchString(); |
| 135 | 135 | |
| 136 | - foreach($this->searchTerms as $term) { |
|
| 137 | - if(!mb_stristr($haystack, $term)) { |
|
| 136 | + foreach ($this->searchTerms as $term) { |
|
| 137 | + if (!mb_stristr($haystack, $term)) { |
|
| 138 | 138 | return false; |
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | $status = $this->getValue($this->vars['status']); |
| 144 | - if($status === 'untranslated' && $string->isTranslated()) { |
|
| 144 | + if ($status === 'untranslated' && $string->isTranslated()) { |
|
| 145 | 145 | return false; |
| 146 | - } else if($status === 'translated' && !$string->isTranslated()) { |
|
| 146 | + } else if ($status === 'translated' && !$string->isTranslated()) { |
|
| 147 | 147 | return false; |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | $location = $this->getValue($this->vars['location']); |
| 151 | - if($location === 'client' && !$string->hasLanguageType('Javascript')) { |
|
| 151 | + if ($location === 'client' && !$string->hasLanguageType('Javascript')) { |
|
| 152 | 152 | return false; |
| 153 | - } else if($location === 'server' && !$string->hasLanguageType('PHP')) { |
|
| 153 | + } else if ($location === 'server' && !$string->hasLanguageType('PHP')) { |
|
| 154 | 154 | return false; |
| 155 | 155 | } |
| 156 | 156 | |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | <div class="form-hiddens"> |
| 176 | 176 | <?php |
| 177 | 177 | $params = $this->editor->getRequestParams(); |
| 178 | - foreach($params as $name => $value) { |
|
| 178 | + foreach ($params as $name => $value) { |
|
| 179 | 179 | ?> |
| 180 | 180 | <input type="hidden" name="<?php echo $name ?>" value="<?php echo $value ?>"> |
| 181 | 181 | <?php |
@@ -251,10 +251,10 @@ discard block |
||
| 251 | 251 | ?> |
| 252 | 252 | <select class="form-control" name="<?php echo $filterName ?>"> |
| 253 | 253 | <?php |
| 254 | - foreach($entries as $entry) |
|
| 254 | + foreach ($entries as $entry) |
|
| 255 | 255 | { |
| 256 | 256 | $selected = ''; |
| 257 | - if($entry['value'] === $value) { |
|
| 257 | + if ($entry['value'] === $value) { |
|
| 258 | 258 | $selected = ' selected'; |
| 259 | 259 | } |
| 260 | 260 | |
@@ -50,8 +50,7 @@ discard block |
||
| 50 | 50 | foreach($defaults as $name => $val) { |
| 51 | 51 | $this->setValue($name, $val); |
| 52 | 52 | } |
| 53 | - } |
|
| 54 | - else if($this->request->getBool($this->vars['filter'])) |
|
| 53 | + } else if($this->request->getBool($this->vars['filter'])) |
|
| 55 | 54 | { |
| 56 | 55 | $this->parseSearchTerms($this->request->getParam($this->vars['search'])); |
| 57 | 56 | |
@@ -72,8 +71,7 @@ discard block |
||
| 72 | 71 | ->setEnum('', 'client', 'server') |
| 73 | 72 | ->get('') |
| 74 | 73 | ); |
| 75 | - } |
|
| 76 | - else |
|
| 74 | + } else |
|
| 77 | 75 | { |
| 78 | 76 | $this->parseSearchTerms($this->getValue($this->vars['search'])); |
| 79 | 77 | } |
@@ -20,25 +20,25 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | class Localization_Editor_Filters |
| 22 | 22 | { |
| 23 | - /** |
|
| 24 | - * @var Localization_Editor |
|
| 25 | - */ |
|
| 23 | + /** |
|
| 24 | + * @var Localization_Editor |
|
| 25 | + */ |
|
| 26 | 26 | protected $editor; |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * @var \AppUtils\Request |
|
| 30 | - */ |
|
| 28 | + /** |
|
| 29 | + * @var \AppUtils\Request |
|
| 30 | + */ |
|
| 31 | 31 | |
| 32 | 32 | protected $request; |
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * @var string |
|
| 36 | - */ |
|
| 34 | + /** |
|
| 35 | + * @var string |
|
| 36 | + */ |
|
| 37 | 37 | protected $sessionName = 'localize_filters'; |
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @var string[]string |
|
| 41 | - */ |
|
| 39 | + /** |
|
| 40 | + * @var string[]string |
|
| 41 | + */ |
|
| 42 | 42 | protected $vars = array( |
| 43 | 43 | 'resetfilter' => '', |
| 44 | 44 | 'filter' => '', |
@@ -191,13 +191,13 @@ discard block |
||
| 191 | 191 | <form class="form-inline"> |
| 192 | 192 | <div class="form-hiddens"> |
| 193 | 193 | <?php |
| 194 | - $params = $this->editor->getRequestParams(); |
|
| 195 | - foreach($params as $name => $value) { |
|
| 196 | - ?> |
|
| 194 | + $params = $this->editor->getRequestParams(); |
|
| 195 | + foreach($params as $name => $value) { |
|
| 196 | + ?> |
|
| 197 | 197 | <input type="hidden" name="<?php echo $name ?>" value="<?php echo $value ?>"> |
| 198 | 198 | <?php |
| 199 | - } |
|
| 200 | - ?> |
|
| 199 | + } |
|
| 200 | + ?> |
|
| 201 | 201 | </div> |
| 202 | 202 | <div class="form-row"> |
| 203 | 203 | <div class="col-auto"> |
@@ -205,42 +205,42 @@ discard block |
||
| 205 | 205 | </div> |
| 206 | 206 | <div class="col-auto"> |
| 207 | 207 | <?php |
| 208 | - echo $this->renderSelect( |
|
| 209 | - $this->vars['status'], |
|
| 210 | - array( |
|
| 211 | - array( |
|
| 212 | - 'value' => '', |
|
| 213 | - 'label' => t('Status...') |
|
| 214 | - ), |
|
| 215 | - array( |
|
| 216 | - 'value' => 'untranslated', |
|
| 217 | - 'label' => t('Not translated') |
|
| 218 | - ), |
|
| 219 | - array( |
|
| 220 | - 'value' => 'translated', |
|
| 221 | - 'label' => t('Translated') |
|
| 222 | - ) |
|
| 223 | - ) |
|
| 224 | - ); |
|
| 208 | + echo $this->renderSelect( |
|
| 209 | + $this->vars['status'], |
|
| 210 | + array( |
|
| 211 | + array( |
|
| 212 | + 'value' => '', |
|
| 213 | + 'label' => t('Status...') |
|
| 214 | + ), |
|
| 215 | + array( |
|
| 216 | + 'value' => 'untranslated', |
|
| 217 | + 'label' => t('Not translated') |
|
| 218 | + ), |
|
| 219 | + array( |
|
| 220 | + 'value' => 'translated', |
|
| 221 | + 'label' => t('Translated') |
|
| 222 | + ) |
|
| 223 | + ) |
|
| 224 | + ); |
|
| 225 | 225 | |
| 226 | - echo $this->renderSelect( |
|
| 227 | - $this->vars['location'], |
|
| 228 | - array( |
|
| 229 | - array( |
|
| 230 | - 'value' => '', |
|
| 231 | - 'label' => t('Location...') |
|
| 232 | - ), |
|
| 233 | - array( |
|
| 234 | - 'value' => 'client', |
|
| 235 | - 'label' => t('Clientside') |
|
| 236 | - ), |
|
| 237 | - array( |
|
| 238 | - 'value' => 'server', |
|
| 239 | - 'label' => t('Serverside') |
|
| 240 | - ) |
|
| 241 | - ) |
|
| 242 | - ); |
|
| 243 | - ?> |
|
| 226 | + echo $this->renderSelect( |
|
| 227 | + $this->vars['location'], |
|
| 228 | + array( |
|
| 229 | + array( |
|
| 230 | + 'value' => '', |
|
| 231 | + 'label' => t('Location...') |
|
| 232 | + ), |
|
| 233 | + array( |
|
| 234 | + 'value' => 'client', |
|
| 235 | + 'label' => t('Clientside') |
|
| 236 | + ), |
|
| 237 | + array( |
|
| 238 | + 'value' => 'server', |
|
| 239 | + 'label' => t('Serverside') |
|
| 240 | + ) |
|
| 241 | + ) |
|
| 242 | + ); |
|
| 243 | + ?> |
|
| 244 | 244 | </div> |
| 245 | 245 | <div class="col-auto"> |
| 246 | 246 | <button type="submit" name="<?php echo $this->vars['filter'] ?>" value="yes" class="btn btn-primary mb-2" title="<?php pt('Filter the list with the selected criteria.') ?>" data-toggle="tooltip"> |
@@ -255,9 +255,9 @@ discard block |
||
| 255 | 255 | </form> |
| 256 | 256 | <p> |
| 257 | 257 | <small class="text-muted"><?php |
| 258 | - pts('Hint:'); |
|
| 259 | - pt('Search works in translated and untranslated text, as well as the file name.') |
|
| 260 | - ?></small> |
|
| 258 | + pts('Hint:'); |
|
| 259 | + pt('Search works in translated and untranslated text, as well as the file name.') |
|
| 260 | + ?></small> |
|
| 261 | 261 | </p> |
| 262 | 262 | <br> |
| 263 | 263 | <?php |
@@ -24,14 +24,14 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | public function scan() |
| 26 | 26 | { |
| 27 | - if(isset($this->collection)) { |
|
| 27 | + if (isset($this->collection)) { |
|
| 28 | 28 | $this->collection = null; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | $this->timeStart = microtime(true); |
| 32 | 32 | |
| 33 | 33 | $sources = Localization::getSources(); |
| 34 | - foreach($sources as $source) |
|
| 34 | + foreach ($sources as $source) |
|
| 35 | 35 | { |
| 36 | 36 | $source->scan($this); |
| 37 | 37 | } |
@@ -45,11 +45,11 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | public function load() |
| 47 | 47 | { |
| 48 | - if(!$this->isScanAvailable()) { |
|
| 48 | + if (!$this->isScanAvailable()) { |
|
| 49 | 49 | return; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - if($this->loaded) { |
|
| 52 | + if ($this->loaded) { |
|
| 53 | 53 | return; |
| 54 | 54 | } |
| 55 | 55 | |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | $data = \AppUtils\FileHelper::parseJSONFile($this->storageFile); |
| 59 | 59 | |
| 60 | - if($this->getCollection()->fromArray($data) === true) { |
|
| 60 | + if ($this->getCollection()->fromArray($data) === true) { |
|
| 61 | 61 | return; |
| 62 | 62 | } |
| 63 | 63 | |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | |
| 81 | 81 | public function getParser() |
| 82 | 82 | { |
| 83 | - if(!isset($this->parser)) { |
|
| 83 | + if (!isset($this->parser)) { |
|
| 84 | 84 | $this->parser = new Localization_Parser($this); |
| 85 | 85 | } |
| 86 | 86 | |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | |
| 95 | 95 | public function getCollection() : Localization_Scanner_StringsCollection |
| 96 | 96 | { |
| 97 | - if(!isset($this->collection)) { |
|
| 97 | + if (!isset($this->collection)) { |
|
| 98 | 98 | $this->collection = new Localization_Scanner_StringsCollection($this); |
| 99 | 99 | } |
| 100 | 100 | |
@@ -4,24 +4,24 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | class Localization_Scanner |
| 6 | 6 | { |
| 7 | - /** |
|
| 8 | - * @var float |
|
| 9 | - */ |
|
| 7 | + /** |
|
| 8 | + * @var float |
|
| 9 | + */ |
|
| 10 | 10 | protected $timeStart; |
| 11 | 11 | |
| 12 | - /** |
|
| 13 | - * @var float |
|
| 14 | - */ |
|
| 12 | + /** |
|
| 13 | + * @var float |
|
| 14 | + */ |
|
| 15 | 15 | protected $timeEnd; |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * @var array |
|
| 19 | - */ |
|
| 17 | + /** |
|
| 18 | + * @var array |
|
| 19 | + */ |
|
| 20 | 20 | protected $stringInfos = array(); |
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * @var string |
|
| 24 | - */ |
|
| 22 | + /** |
|
| 23 | + * @var string |
|
| 24 | + */ |
|
| 25 | 25 | protected $storageFile; |
| 26 | 26 | |
| 27 | 27 | /** |
@@ -91,9 +91,9 @@ discard block |
||
| 91 | 91 | \AppUtils\FileHelper::saveAsJSON($data, $this->storageFile); |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * @var Localization_Parser |
|
| 96 | - */ |
|
| 94 | + /** |
|
| 95 | + * @var Localization_Parser |
|
| 96 | + */ |
|
| 97 | 97 | protected $parser; |
| 98 | 98 | |
| 99 | 99 | public function getParser() |
@@ -149,12 +149,12 @@ discard block |
||
| 149 | 149 | return $this->getCollection()->countWarnings(); |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - /** |
|
| 153 | - * Retrieves all warnings that have been registered |
|
| 154 | - * during the last search for translateable texts. |
|
| 155 | - * |
|
| 156 | - * @return \AppLocalize\Localization_Scanner_StringsCollection_Warning[] |
|
| 157 | - */ |
|
| 152 | + /** |
|
| 153 | + * Retrieves all warnings that have been registered |
|
| 154 | + * during the last search for translateable texts. |
|
| 155 | + * |
|
| 156 | + * @return \AppLocalize\Localization_Scanner_StringsCollection_Warning[] |
|
| 157 | + */ |
|
| 158 | 158 | public function getWarnings() |
| 159 | 159 | { |
| 160 | 160 | return $this->getCollection()->getWarnings(); |
@@ -197,8 +197,7 @@ |
||
| 197 | 197 | if ($decimals == '-') { |
| 198 | 198 | $decimals = 0; |
| 199 | 199 | } |
| 200 | - } |
|
| 201 | - else |
|
| 200 | + } else |
|
| 202 | 201 | { |
| 203 | 202 | $decimals = null; |
| 204 | 203 | $thousands = floatval(implode('', $parts)); |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | return self::$instances[$id]; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - $className = '\AppLocalize\Localization_Currency_' . $id; |
|
| 54 | + $className = '\AppLocalize\Localization_Currency_'.$id; |
|
| 55 | 55 | |
| 56 | 56 | return new $className($country); |
| 57 | 57 | } |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | */ |
| 92 | 92 | public static function isCurrencyKnown($currencyName) |
| 93 | 93 | { |
| 94 | - return file_exists(__DIR__ . '/Currency/' . $currencyName . '.php'); |
|
| 94 | + return file_exists(__DIR__.'/Currency/'.$currencyName.'.php'); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /** |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | return $this->country->getNumberDecimalsSeparator(); |
| 292 | 292 | } |
| 293 | 293 | |
| 294 | - public function makeReadable($number, $decimalPositions = 2, $addSymbol=true) |
|
| 294 | + public function makeReadable($number, $decimalPositions = 2, $addSymbol = true) |
|
| 295 | 295 | { |
| 296 | 296 | if ($number === null || $number === '') { |
| 297 | 297 | return null; |
@@ -301,14 +301,14 @@ discard block |
||
| 301 | 301 | |
| 302 | 302 | $number = $this->formatNumber($parsed->getFloat(), $decimalPositions); |
| 303 | 303 | |
| 304 | - if(!$addSymbol) { |
|
| 304 | + if (!$addSymbol) { |
|
| 305 | 305 | return $number; |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | if ($this->isSymbolOnFront()) { |
| 309 | - return $this->getSymbol() . ' ' . $number; |
|
| 309 | + return $this->getSymbol().' '.$number; |
|
| 310 | 310 | } |
| 311 | 311 | |
| 312 | - return $number . ' ' . $this->getSymbol(); |
|
| 312 | + return $number.' '.$this->getSymbol(); |
|
| 313 | 313 | } |
| 314 | 314 | } |
| 315 | 315 | \ No newline at end of file |
@@ -40,7 +40,7 @@ |
||
| 40 | 40 | public function getFloat() |
| 41 | 41 | { |
| 42 | 42 | if ($this->decimals) { |
| 43 | - return floatval($this->number . '.' . $this->decimals); |
|
| 43 | + return floatval($this->number.'.'.$this->decimals); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | return $this->number; |
@@ -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) |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | function __construct($i = null) |
| 45 | 45 | { |
| 46 | 46 | if (!is_null($i)) { |
| 47 | - $this->i = (int)$i; |
|
| 47 | + $this->i = (int) $i; |
|
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | { |
| 85 | 85 | if (is_int($i)) { |
| 86 | 86 | if (!isset($this->names[$i])) { |
| 87 | - trigger_error("symbol " . var_export($i, true) . " is unknown in " . get_class($this), E_USER_NOTICE); |
|
| 87 | + trigger_error("symbol ".var_export($i, true)." is unknown in ".get_class($this), E_USER_NOTICE); |
|
| 88 | 88 | |
| 89 | 89 | return 'UNKNOWN'; |
| 90 | 90 | } else { |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | } |
| 93 | 93 | } else { |
| 94 | 94 | if (!isset($this->literals[$i])) { |
| 95 | - trigger_error("literal symbol " . var_export($i, true) . " is unknown in " . get_class($this), E_USER_NOTICE); |
|
| 95 | + trigger_error("literal symbol ".var_export($i, true)." is unknown in ".get_class($this), E_USER_NOTICE); |
|
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | 98 | |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | function dump() |
| 113 | 113 | { |
| 114 | 114 | asort($this->names, SORT_STRING); |
| 115 | - $t = max(2, strlen((string)$this->i)); |
|
| 115 | + $t = max(2, strlen((string) $this->i)); |
|
| 116 | 116 | foreach ($this->names as $i => $n) { |
| 117 | 117 | $i = str_pad($i, $t, ' ', STR_PAD_LEFT); |
| 118 | 118 | echo "$i => $n \n"; |
@@ -52,12 +52,12 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | const NAMESPACE_CONTENT = '__content'; |
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Collection of all locales by namespace (application, content, custom...). |
|
| 57 | - * |
|
| 58 | - * @var array |
|
| 59 | - * @see Localization::addLocale() |
|
| 60 | - */ |
|
| 55 | + /** |
|
| 56 | + * Collection of all locales by namespace (application, content, custom...). |
|
| 57 | + * |
|
| 58 | + * @var array |
|
| 59 | + * @see Localization::addLocale() |
|
| 60 | + */ |
|
| 61 | 61 | protected static $locales = array(); |
| 62 | 62 | |
| 63 | 63 | /** |
@@ -66,57 +66,57 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | private static $initDone = false; |
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * Path to the file in which the scanner results are stored. |
|
| 71 | - * @var string |
|
| 72 | - * @see Localization::configure() |
|
| 73 | - */ |
|
| 69 | + /** |
|
| 70 | + * Path to the file in which the scanner results are stored. |
|
| 71 | + * @var string |
|
| 72 | + * @see Localization::configure() |
|
| 73 | + */ |
|
| 74 | 74 | protected static $storageFile = ''; |
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * Path to the folder into which the client libraries are written. |
|
| 78 | - * @var string |
|
| 79 | - * @see Localization::setClientLibrariesFolder() |
|
| 80 | - */ |
|
| 76 | + /** |
|
| 77 | + * Path to the folder into which the client libraries are written. |
|
| 78 | + * @var string |
|
| 79 | + * @see Localization::setClientLibrariesFolder() |
|
| 80 | + */ |
|
| 81 | 81 | protected static $clientFolder = ''; |
| 82 | 82 | |
| 83 | - /** |
|
| 84 | - * If this key changes, client libraries are refreshed. |
|
| 85 | - * @var string |
|
| 86 | - * @see Localization::setClientLibrariesCacheKey() |
|
| 87 | - */ |
|
| 83 | + /** |
|
| 84 | + * If this key changes, client libraries are refreshed. |
|
| 85 | + * @var string |
|
| 86 | + * @see Localization::setClientLibrariesCacheKey() |
|
| 87 | + */ |
|
| 88 | 88 | protected static $clientCacheKey = ''; |
| 89 | 89 | |
| 90 | - /** |
|
| 91 | - * Whether the configuration has been made. |
|
| 92 | - * @var bool |
|
| 93 | - * @see Localization::configure() |
|
| 94 | - */ |
|
| 90 | + /** |
|
| 91 | + * Whether the configuration has been made. |
|
| 92 | + * @var bool |
|
| 93 | + * @see Localization::configure() |
|
| 94 | + */ |
|
| 95 | 95 | protected static $configured = false; |
| 96 | 96 | |
| 97 | - /** |
|
| 98 | - * Stores event listener instances. |
|
| 99 | - * @var array |
|
| 100 | - */ |
|
| 97 | + /** |
|
| 98 | + * Stores event listener instances. |
|
| 99 | + * @var array |
|
| 100 | + */ |
|
| 101 | 101 | protected static $listeners = array(); |
| 102 | 102 | |
| 103 | - /** |
|
| 104 | - * @var integer |
|
| 105 | - * @see Localization::addEventListener() |
|
| 106 | - */ |
|
| 103 | + /** |
|
| 104 | + * @var integer |
|
| 105 | + * @see Localization::addEventListener() |
|
| 106 | + */ |
|
| 107 | 107 | protected static $listenersCounter = 0; |
| 108 | 108 | |
| 109 | - /** |
|
| 110 | - * @var Localization_Translator|NULL |
|
| 111 | - */ |
|
| 109 | + /** |
|
| 110 | + * @var Localization_Translator|NULL |
|
| 111 | + */ |
|
| 112 | 112 | protected static $translator; |
| 113 | 113 | |
| 114 | - /** |
|
| 115 | - * Initializes the localization layer. This is done |
|
| 116 | - * automatically, and only once per request. |
|
| 117 | - * |
|
| 118 | - * (Called at the end of this file) |
|
| 119 | - */ |
|
| 114 | + /** |
|
| 115 | + * Initializes the localization layer. This is done |
|
| 116 | + * automatically, and only once per request. |
|
| 117 | + * |
|
| 118 | + * (Called at the end of this file) |
|
| 119 | + */ |
|
| 120 | 120 | public static function init() : void |
| 121 | 121 | { |
| 122 | 122 | if(self::$initDone) { |
@@ -155,12 +155,12 @@ discard block |
||
| 155 | 155 | return self::getLocalesByNS(self::NAMESPACE_APPLICATION); |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - /** |
|
| 159 | - * Retrieves all locales in the specified namespace. |
|
| 160 | - * |
|
| 161 | - * @param string $namespace |
|
| 162 | - * @return Localization_Locale[] |
|
| 163 | - */ |
|
| 158 | + /** |
|
| 159 | + * Retrieves all locales in the specified namespace. |
|
| 160 | + * |
|
| 161 | + * @param string $namespace |
|
| 162 | + * @return Localization_Locale[] |
|
| 163 | + */ |
|
| 164 | 164 | public static function getLocalesByNS(string $namespace) |
| 165 | 165 | { |
| 166 | 166 | if(isset(self::$locales[$namespace])) { |
@@ -177,35 +177,35 @@ discard block |
||
| 177 | 177 | ); |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - /** |
|
| 181 | - * Adds an application locale to use in the application. |
|
| 182 | - * |
|
| 183 | - * @param string $localeName |
|
| 184 | - * @return Localization_Locale |
|
| 185 | - */ |
|
| 180 | + /** |
|
| 181 | + * Adds an application locale to use in the application. |
|
| 182 | + * |
|
| 183 | + * @param string $localeName |
|
| 184 | + * @return Localization_Locale |
|
| 185 | + */ |
|
| 186 | 186 | public static function addAppLocale(string $localeName) : Localization_Locale |
| 187 | 187 | { |
| 188 | 188 | return self::addLocaleByNS($localeName, self::NAMESPACE_APPLICATION); |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - /** |
|
| 192 | - * Adds a content locale to use for content in the application. |
|
| 193 | - * |
|
| 194 | - * @param string $localeName |
|
| 195 | - * @return Localization_Locale |
|
| 196 | - */ |
|
| 191 | + /** |
|
| 192 | + * Adds a content locale to use for content in the application. |
|
| 193 | + * |
|
| 194 | + * @param string $localeName |
|
| 195 | + * @return Localization_Locale |
|
| 196 | + */ |
|
| 197 | 197 | public static function addContentLocale(string $localeName) : Localization_Locale |
| 198 | 198 | { |
| 199 | 199 | return self::addLocaleByNS($localeName, self::NAMESPACE_CONTENT); |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | - /** |
|
| 203 | - * Adds a locale to the specified namespace. |
|
| 204 | - * |
|
| 205 | - * @param string $localeName |
|
| 206 | - * @param string $namespace |
|
| 207 | - * @return Localization_Locale |
|
| 208 | - */ |
|
| 202 | + /** |
|
| 203 | + * Adds a locale to the specified namespace. |
|
| 204 | + * |
|
| 205 | + * @param string $localeName |
|
| 206 | + * @param string $namespace |
|
| 207 | + * @return Localization_Locale |
|
| 208 | + */ |
|
| 209 | 209 | public static function addLocaleByNS(string $localeName, string $namespace) : Localization_Locale |
| 210 | 210 | { |
| 211 | 211 | if(!isset(self::$locales[$namespace])) { |
@@ -247,11 +247,11 @@ discard block |
||
| 247 | 247 | return new $className(); |
| 248 | 248 | } |
| 249 | 249 | |
| 250 | - /** |
|
| 251 | - * Retrieves the currency of the selected app locale. |
|
| 252 | - * |
|
| 253 | - * @return Localization_Currency |
|
| 254 | - */ |
|
| 250 | + /** |
|
| 251 | + * Retrieves the currency of the selected app locale. |
|
| 252 | + * |
|
| 253 | + * @return Localization_Currency |
|
| 254 | + */ |
|
| 255 | 255 | public static function getAppCurrency() : Localization_Currency |
| 256 | 256 | { |
| 257 | 257 | return self::getCurrencyNS(self::NAMESPACE_APPLICATION); |
@@ -288,44 +288,44 @@ discard block |
||
| 288 | 288 | return self::getSelectedLocaleByNS(self::NAMESPACE_APPLICATION); |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | - /** |
|
| 292 | - * Retrieves the name of the selected application locale. |
|
| 293 | - * |
|
| 294 | - * @return string |
|
| 295 | - */ |
|
| 291 | + /** |
|
| 292 | + * Retrieves the name of the selected application locale. |
|
| 293 | + * |
|
| 294 | + * @return string |
|
| 295 | + */ |
|
| 296 | 296 | public static function getAppLocaleName() : string |
| 297 | 297 | { |
| 298 | 298 | return self::getLocaleNameByNS(self::NAMESPACE_APPLICATION); |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | - /** |
|
| 302 | - * Retrieves the names of the available application locales. |
|
| 303 | - * @return string[] |
|
| 304 | - */ |
|
| 301 | + /** |
|
| 302 | + * Retrieves the names of the available application locales. |
|
| 303 | + * @return string[] |
|
| 304 | + */ |
|
| 305 | 305 | public static function getAppLocaleNames() : array |
| 306 | 306 | { |
| 307 | 307 | return self::getLocaleNamesByNS(self::NAMESPACE_APPLICATION); |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | - /** |
|
| 311 | - * Retrieves the selected locale name in the specified namespace. |
|
| 312 | - * |
|
| 313 | - * @param string $namespace |
|
| 314 | - * @throws Localization_Exception |
|
| 315 | - * @return string |
|
| 316 | - */ |
|
| 310 | + /** |
|
| 311 | + * Retrieves the selected locale name in the specified namespace. |
|
| 312 | + * |
|
| 313 | + * @param string $namespace |
|
| 314 | + * @throws Localization_Exception |
|
| 315 | + * @return string |
|
| 316 | + */ |
|
| 317 | 317 | public static function getLocaleNameByNS(string $namespace) : string |
| 318 | 318 | { |
| 319 | 319 | return self::getSelectedKeyByNS('name', $namespace); |
| 320 | 320 | } |
| 321 | 321 | |
| 322 | - /** |
|
| 323 | - * Retrieves the selected locale instance for the specified namespace. |
|
| 324 | - * |
|
| 325 | - * @param string $namespace |
|
| 326 | - * @return Localization_Locale |
|
| 327 | - * @throws Localization_Exception |
|
| 328 | - */ |
|
| 322 | + /** |
|
| 323 | + * Retrieves the selected locale instance for the specified namespace. |
|
| 324 | + * |
|
| 325 | + * @param string $namespace |
|
| 326 | + * @return Localization_Locale |
|
| 327 | + * @throws Localization_Exception |
|
| 328 | + */ |
|
| 329 | 329 | public static function getSelectedLocaleByNS(string $namespace) : Localization_Locale |
| 330 | 330 | { |
| 331 | 331 | return self::getSelectedKeyByNS('locale', $namespace); |
@@ -350,20 +350,20 @@ discard block |
||
| 350 | 350 | ); |
| 351 | 351 | } |
| 352 | 352 | |
| 353 | - /** |
|
| 354 | - * Stores the selected locale names by namespace. |
|
| 355 | - * @var array |
|
| 356 | - */ |
|
| 353 | + /** |
|
| 354 | + * Stores the selected locale names by namespace. |
|
| 355 | + * @var array |
|
| 356 | + */ |
|
| 357 | 357 | protected static $selected = array(); |
| 358 | 358 | |
| 359 | - /** |
|
| 360 | - * Selects the active locale for the specified namespace. |
|
| 361 | - * |
|
| 362 | - * @param string $localeName |
|
| 363 | - * @param string $namespace |
|
| 364 | - * @return Localization_Locale |
|
| 365 | - * @throws Localization_Exception |
|
| 366 | - */ |
|
| 359 | + /** |
|
| 360 | + * Selects the active locale for the specified namespace. |
|
| 361 | + * |
|
| 362 | + * @param string $localeName |
|
| 363 | + * @param string $namespace |
|
| 364 | + * @return Localization_Locale |
|
| 365 | + * @throws Localization_Exception |
|
| 366 | + */ |
|
| 367 | 367 | public static function selectLocaleByNS(string $localeName, string $namespace) : Localization_Locale |
| 368 | 368 | { |
| 369 | 369 | self::requireNamespace($namespace); |
@@ -399,13 +399,13 @@ discard block |
||
| 399 | 399 | return $locale; |
| 400 | 400 | } |
| 401 | 401 | |
| 402 | - /** |
|
| 403 | - * Triggers the specified event, with the provided arguments. |
|
| 404 | - * |
|
| 405 | - * @param string $name The event name. |
|
| 406 | - * @param array $argsList |
|
| 407 | - * @see Localization_Event |
|
| 408 | - */ |
|
| 402 | + /** |
|
| 403 | + * Triggers the specified event, with the provided arguments. |
|
| 404 | + * |
|
| 405 | + * @param string $name The event name. |
|
| 406 | + * @param array $argsList |
|
| 407 | + * @see Localization_Event |
|
| 408 | + */ |
|
| 409 | 409 | protected static function triggerEvent(string $name, array $argsList) : Localization_Event |
| 410 | 410 | { |
| 411 | 411 | $class = '\AppLocalize\Localization_Event_'.$name; |
@@ -426,14 +426,14 @@ discard block |
||
| 426 | 426 | return $event; |
| 427 | 427 | } |
| 428 | 428 | |
| 429 | - /** |
|
| 430 | - * Adds a listener to the specified event name. |
|
| 431 | - * |
|
| 432 | - * @param string $eventName |
|
| 433 | - * @param callable $callback |
|
| 434 | - * @param array $args Additional arguments to add to the event |
|
| 435 | - * @return int The listener number. |
|
| 436 | - */ |
|
| 429 | + /** |
|
| 430 | + * Adds a listener to the specified event name. |
|
| 431 | + * |
|
| 432 | + * @param string $eventName |
|
| 433 | + * @param callable $callback |
|
| 434 | + * @param array $args Additional arguments to add to the event |
|
| 435 | + * @return int The listener number. |
|
| 436 | + */ |
|
| 437 | 437 | public static function addEventListener(string $eventName, $callback, array $args=array()) : int |
| 438 | 438 | { |
| 439 | 439 | if(!isset(self::$listeners[$eventName])) { |
@@ -463,43 +463,43 @@ discard block |
||
| 463 | 463 | return self::$listenersCounter; |
| 464 | 464 | } |
| 465 | 465 | |
| 466 | - /** |
|
| 467 | - * Adds an event listener for the <code>LocaleChanged</code> event, |
|
| 468 | - * which is triggered every time a locale is changed in any of the |
|
| 469 | - * available namespaces. |
|
| 470 | - * |
|
| 471 | - * The first parameter of the callback is always the event instance. |
|
| 472 | - * |
|
| 473 | - * @param callable $callback The listener function to call. |
|
| 474 | - * @param array $args Optional indexed array with additional arguments to pass on to the callback function. |
|
| 475 | - * @return int |
|
| 476 | - * @see Localization_Event_LocaleChanged |
|
| 477 | - */ |
|
| 466 | + /** |
|
| 467 | + * Adds an event listener for the <code>LocaleChanged</code> event, |
|
| 468 | + * which is triggered every time a locale is changed in any of the |
|
| 469 | + * available namespaces. |
|
| 470 | + * |
|
| 471 | + * The first parameter of the callback is always the event instance. |
|
| 472 | + * |
|
| 473 | + * @param callable $callback The listener function to call. |
|
| 474 | + * @param array $args Optional indexed array with additional arguments to pass on to the callback function. |
|
| 475 | + * @return int |
|
| 476 | + * @see Localization_Event_LocaleChanged |
|
| 477 | + */ |
|
| 478 | 478 | public static function onLocaleChanged($callback, array $args=array()) : int |
| 479 | 479 | { |
| 480 | 480 | return self::addEventListener('LocaleChanged', $callback, $args); |
| 481 | 481 | } |
| 482 | 482 | |
| 483 | - /** |
|
| 484 | - * Selects the application locale to use. |
|
| 485 | - * |
|
| 486 | - * @param string $localeName |
|
| 487 | - * @return Localization_Locale |
|
| 488 | - */ |
|
| 483 | + /** |
|
| 484 | + * Selects the application locale to use. |
|
| 485 | + * |
|
| 486 | + * @param string $localeName |
|
| 487 | + * @return Localization_Locale |
|
| 488 | + */ |
|
| 489 | 489 | public static function selectAppLocale(string $localeName) : Localization_Locale |
| 490 | 490 | { |
| 491 | 491 | return self::selectLocaleByNS($localeName, self::NAMESPACE_APPLICATION); |
| 492 | 492 | } |
| 493 | 493 | |
| 494 | - /** |
|
| 495 | - * Retrieves an application locale by its name. |
|
| 496 | - * Note that the locale must have been added first. |
|
| 497 | - * |
|
| 498 | - * @param string $localeName |
|
| 499 | - * @throws Localization_Exception |
|
| 500 | - * @return Localization_Locale |
|
| 501 | - * @see Localization::appLocaleExists() |
|
| 502 | - */ |
|
| 494 | + /** |
|
| 495 | + * Retrieves an application locale by its name. |
|
| 496 | + * Note that the locale must have been added first. |
|
| 497 | + * |
|
| 498 | + * @param string $localeName |
|
| 499 | + * @throws Localization_Exception |
|
| 500 | + * @return Localization_Locale |
|
| 501 | + * @see Localization::appLocaleExists() |
|
| 502 | + */ |
|
| 503 | 503 | public static function getAppLocaleByName(string $localeName) : Localization_Locale |
| 504 | 504 | { |
| 505 | 505 | return self::getLocaleByNameNS($localeName, self::NAMESPACE_APPLICATION); |
@@ -533,22 +533,22 @@ discard block |
||
| 533 | 533 | return self::getLocalesByNS(self::NAMESPACE_CONTENT); |
| 534 | 534 | } |
| 535 | 535 | |
| 536 | - /** |
|
| 537 | - * Retrieves the names of all content locales that have been added. |
|
| 538 | - * @return string[] |
|
| 539 | - */ |
|
| 536 | + /** |
|
| 537 | + * Retrieves the names of all content locales that have been added. |
|
| 538 | + * @return string[] |
|
| 539 | + */ |
|
| 540 | 540 | public static function getContentLocaleNames() |
| 541 | 541 | { |
| 542 | 542 | return self::getLocaleNamesByNS(self::NAMESPACE_CONTENT); |
| 543 | 543 | } |
| 544 | 544 | |
| 545 | - /** |
|
| 546 | - * Retrieves all locale names available in the specified namespace. |
|
| 547 | - * The names are sorted alphabetically. |
|
| 548 | - * |
|
| 549 | - * @param string $namespace |
|
| 550 | - * @return array|array |
|
| 551 | - */ |
|
| 545 | + /** |
|
| 546 | + * Retrieves all locale names available in the specified namespace. |
|
| 547 | + * The names are sorted alphabetically. |
|
| 548 | + * |
|
| 549 | + * @param string $namespace |
|
| 550 | + * @return array|array |
|
| 551 | + */ |
|
| 552 | 552 | public static function getLocaleNamesByNS(string $namespace) |
| 553 | 553 | { |
| 554 | 554 | self::requireNamespace($namespace); |
@@ -558,7 +558,7 @@ discard block |
||
| 558 | 558 | sort($names); |
| 559 | 559 | |
| 560 | 560 | return $names; |
| 561 | - } |
|
| 561 | + } |
|
| 562 | 562 | |
| 563 | 563 | /** |
| 564 | 564 | * Checks by the locale name if the specified locale is |
@@ -587,14 +587,14 @@ discard block |
||
| 587 | 587 | return self::getLocaleByNameNS($localeName, self::NAMESPACE_CONTENT); |
| 588 | 588 | } |
| 589 | 589 | |
| 590 | - /** |
|
| 591 | - * Retrieves a locale by its name in the specified namespace. |
|
| 592 | - * |
|
| 593 | - * @param string $localeName |
|
| 594 | - * @param string $namespace |
|
| 595 | - * @throws Localization_Exception |
|
| 596 | - * @return Localization_Locale |
|
| 597 | - */ |
|
| 590 | + /** |
|
| 591 | + * Retrieves a locale by its name in the specified namespace. |
|
| 592 | + * |
|
| 593 | + * @param string $localeName |
|
| 594 | + * @param string $namespace |
|
| 595 | + * @throws Localization_Exception |
|
| 596 | + * @return Localization_Locale |
|
| 597 | + */ |
|
| 598 | 598 | public static function getLocaleByNameNS(string $localeName, string $namespace) : Localization_Locale |
| 599 | 599 | { |
| 600 | 600 | self::requireNamespace($namespace); |
@@ -654,10 +654,10 @@ discard block |
||
| 654 | 654 | return self::selectLocaleByNS($localeName, self::NAMESPACE_CONTENT); |
| 655 | 655 | } |
| 656 | 656 | |
| 657 | - /** |
|
| 658 | - * Checks whether the localization has been configured entirely. |
|
| 659 | - * @return bool |
|
| 660 | - */ |
|
| 657 | + /** |
|
| 658 | + * Checks whether the localization has been configured entirely. |
|
| 659 | + * @return bool |
|
| 660 | + */ |
|
| 661 | 661 | public static function isConfigured() : bool |
| 662 | 662 | { |
| 663 | 663 | return self::$configured; |
@@ -724,29 +724,29 @@ discard block |
||
| 724 | 724 | ); |
| 725 | 725 | } |
| 726 | 726 | |
| 727 | - /** |
|
| 728 | - * Injects a content locales selector element into the specified |
|
| 729 | - * HTML QuickForm2 container. |
|
| 730 | - * |
|
| 731 | - * @param string $elementName |
|
| 732 | - * @param \HTML_QuickForm2_Container $container |
|
| 733 | - * @param string $label |
|
| 734 | - * @return \HTML_QuickForm2_Element_Select |
|
| 735 | - */ |
|
| 727 | + /** |
|
| 728 | + * Injects a content locales selector element into the specified |
|
| 729 | + * HTML QuickForm2 container. |
|
| 730 | + * |
|
| 731 | + * @param string $elementName |
|
| 732 | + * @param \HTML_QuickForm2_Container $container |
|
| 733 | + * @param string $label |
|
| 734 | + * @return \HTML_QuickForm2_Element_Select |
|
| 735 | + */ |
|
| 736 | 736 | public static function injectContentLocalesSelector(string $elementName, \HTML_QuickForm2_Container $container, string $label='') : \HTML_QuickForm2_Element_Select |
| 737 | 737 | { |
| 738 | 738 | return self::injectLocalesSelectorNS($elementName, self::NAMESPACE_CONTENT, $container, $label); |
| 739 | 739 | } |
| 740 | 740 | |
| 741 | - /** |
|
| 742 | - * Injects an app locales selector element into the specified |
|
| 741 | + /** |
|
| 742 | + * Injects an app locales selector element into the specified |
|
| 743 | 743 | * HTML QuickForm2 container. |
| 744 | 744 | * |
| 745 | - * @param string $elementName |
|
| 746 | - * @param \HTML_QuickForm2_Container $container |
|
| 747 | - * @param string $label |
|
| 748 | - * @return \HTML_QuickForm2_Element_Select |
|
| 749 | - */ |
|
| 745 | + * @param string $elementName |
|
| 746 | + * @param \HTML_QuickForm2_Container $container |
|
| 747 | + * @param string $label |
|
| 748 | + * @return \HTML_QuickForm2_Element_Select |
|
| 749 | + */ |
|
| 750 | 750 | public static function injectAppLocalesSelector(string $elementName, \HTML_QuickForm2_Container $container, string $label='') : \HTML_QuickForm2_Element_Select |
| 751 | 751 | { |
| 752 | 752 | return self::injectLocalesSelectorNS($elementName, self::NAMESPACE_APPLICATION, $container, $label); |
@@ -781,26 +781,26 @@ discard block |
||
| 781 | 781 | return $select; |
| 782 | 782 | } |
| 783 | 783 | |
| 784 | - /** |
|
| 785 | - * @var Localization_Source[] |
|
| 786 | - */ |
|
| 784 | + /** |
|
| 785 | + * @var Localization_Source[] |
|
| 786 | + */ |
|
| 787 | 787 | protected static $sources = array(); |
| 788 | 788 | |
| 789 | - /** |
|
| 790 | - * @var string[] |
|
| 791 | - */ |
|
| 789 | + /** |
|
| 790 | + * @var string[] |
|
| 791 | + */ |
|
| 792 | 792 | protected static $excludeFolders = array(); |
| 793 | 793 | |
| 794 | - /** |
|
| 795 | - * @var string[] |
|
| 796 | - */ |
|
| 794 | + /** |
|
| 795 | + * @var string[] |
|
| 796 | + */ |
|
| 797 | 797 | protected static $excludeFiles = array(); |
| 798 | 798 | |
| 799 | - /** |
|
| 800 | - * Retrieves all currently available sources. |
|
| 801 | - * |
|
| 802 | - * @return \AppLocalize\Localization_Source[] |
|
| 803 | - */ |
|
| 799 | + /** |
|
| 800 | + * Retrieves all currently available sources. |
|
| 801 | + * |
|
| 802 | + * @return \AppLocalize\Localization_Source[] |
|
| 803 | + */ |
|
| 804 | 804 | public static function getSources() |
| 805 | 805 | { |
| 806 | 806 | return self::$sources; |
@@ -832,10 +832,10 @@ discard block |
||
| 832 | 832 | return $source; |
| 833 | 833 | } |
| 834 | 834 | |
| 835 | - /** |
|
| 836 | - * Retrieves all sources grouped by their group name. |
|
| 837 | - * @return array |
|
| 838 | - */ |
|
| 835 | + /** |
|
| 836 | + * Retrieves all sources grouped by their group name. |
|
| 837 | + * @return array |
|
| 838 | + */ |
|
| 839 | 839 | public static function getSourcesGrouped() |
| 840 | 840 | { |
| 841 | 841 | $sources = self::getSources(); |
@@ -856,11 +856,11 @@ discard block |
||
| 856 | 856 | return $grouped; |
| 857 | 857 | } |
| 858 | 858 | |
| 859 | - /** |
|
| 860 | - * Checks whether a specific source exists by its ID. |
|
| 861 | - * @param string $sourceID |
|
| 862 | - * @return boolean |
|
| 863 | - */ |
|
| 859 | + /** |
|
| 860 | + * Checks whether a specific source exists by its ID. |
|
| 861 | + * @param string $sourceID |
|
| 862 | + * @return boolean |
|
| 863 | + */ |
|
| 864 | 864 | public static function sourceExists(string $sourceID) : bool |
| 865 | 865 | { |
| 866 | 866 | $sources = self::getSources(); |
@@ -873,11 +873,11 @@ discard block |
||
| 873 | 873 | return false; |
| 874 | 874 | } |
| 875 | 875 | |
| 876 | - /** |
|
| 877 | - * Checks whether a specific source exists by its alias. |
|
| 878 | - * @param string $sourceAlias |
|
| 879 | - * @return boolean |
|
| 880 | - */ |
|
| 876 | + /** |
|
| 877 | + * Checks whether a specific source exists by its alias. |
|
| 878 | + * @param string $sourceAlias |
|
| 879 | + * @return boolean |
|
| 880 | + */ |
|
| 881 | 881 | public static function sourceAliasExists(string $sourceAlias) : bool |
| 882 | 882 | { |
| 883 | 883 | $sources = self::getSources(); |
@@ -890,13 +890,13 @@ discard block |
||
| 890 | 890 | return false; |
| 891 | 891 | } |
| 892 | 892 | |
| 893 | - /** |
|
| 894 | - * Retrieves a localization source by its ID. |
|
| 895 | - * |
|
| 896 | - * @param string $sourceID |
|
| 897 | - * @throws Localization_Exception |
|
| 898 | - * @return Localization_Source |
|
| 899 | - */ |
|
| 893 | + /** |
|
| 894 | + * Retrieves a localization source by its ID. |
|
| 895 | + * |
|
| 896 | + * @param string $sourceID |
|
| 897 | + * @throws Localization_Exception |
|
| 898 | + * @return Localization_Source |
|
| 899 | + */ |
|
| 900 | 900 | public static function getSourceByID(string $sourceID) : Localization_Source |
| 901 | 901 | { |
| 902 | 902 | $sources = self::getSources(); |
@@ -942,12 +942,12 @@ discard block |
||
| 942 | 942 | ); |
| 943 | 943 | } |
| 944 | 944 | |
| 945 | - /** |
|
| 946 | - * Creates the scanner instance that is used to find |
|
| 947 | - * all translateable strings in the application. |
|
| 948 | - * |
|
| 949 | - * @return Localization_Scanner |
|
| 950 | - */ |
|
| 945 | + /** |
|
| 946 | + * Creates the scanner instance that is used to find |
|
| 947 | + * all translateable strings in the application. |
|
| 948 | + * |
|
| 949 | + * @return Localization_Scanner |
|
| 950 | + */ |
|
| 951 | 951 | public static function createScanner() : Localization_Scanner |
| 952 | 952 | { |
| 953 | 953 | self::requireConfiguration(); |
@@ -960,14 +960,14 @@ discard block |
||
| 960 | 960 | // FIXME: TODO: Add this |
| 961 | 961 | } |
| 962 | 962 | |
| 963 | - /** |
|
| 964 | - * Configures the localization for the application: |
|
| 965 | - * sets the location of the required files and folders. |
|
| 966 | - * Also updated the client library files as needed. |
|
| 967 | - * |
|
| 968 | - * @param string $storageFile Where to store the file analysis storage file. |
|
| 969 | - * @param string $clientLibrariesFolder Where to put the client libraries and translation files. Will be created if it does not exist. Optional: if not set, client libraries will not be created. |
|
| 970 | - */ |
|
| 963 | + /** |
|
| 964 | + * Configures the localization for the application: |
|
| 965 | + * sets the location of the required files and folders. |
|
| 966 | + * Also updated the client library files as needed. |
|
| 967 | + * |
|
| 968 | + * @param string $storageFile Where to store the file analysis storage file. |
|
| 969 | + * @param string $clientLibrariesFolder Where to put the client libraries and translation files. Will be created if it does not exist. Optional: if not set, client libraries will not be created. |
|
| 970 | + */ |
|
| 971 | 971 | public static function configure(string $storageFile, string $clientLibrariesFolder='') |
| 972 | 972 | { |
| 973 | 973 | self::$configured = true; |
@@ -983,17 +983,17 @@ discard block |
||
| 983 | 983 | } |
| 984 | 984 | } |
| 985 | 985 | |
| 986 | - /** |
|
| 987 | - * Sets a key that is used to verify whether the client |
|
| 988 | - * libraries have to be refreshed. A common use is to set |
|
| 989 | - * this to the application's version number to guarantee |
|
| 990 | - * new texts are automatically used with each release. |
|
| 991 | - * |
|
| 992 | - * NOTE: Otherwise files are refreshed only when saving |
|
| 993 | - * them in the editor UI. |
|
| 994 | - * |
|
| 995 | - * @param string $key |
|
| 996 | - */ |
|
| 986 | + /** |
|
| 987 | + * Sets a key that is used to verify whether the client |
|
| 988 | + * libraries have to be refreshed. A common use is to set |
|
| 989 | + * this to the application's version number to guarantee |
|
| 990 | + * new texts are automatically used with each release. |
|
| 991 | + * |
|
| 992 | + * NOTE: Otherwise files are refreshed only when saving |
|
| 993 | + * them in the editor UI. |
|
| 994 | + * |
|
| 995 | + * @param string $key |
|
| 996 | + */ |
|
| 997 | 997 | public static function setClientLibrariesCacheKey(string $key) |
| 998 | 998 | { |
| 999 | 999 | self::$clientCacheKey = $key; |
@@ -1004,48 +1004,48 @@ discard block |
||
| 1004 | 1004 | return self::$clientCacheKey; |
| 1005 | 1005 | } |
| 1006 | 1006 | |
| 1007 | - /** |
|
| 1008 | - * Sets the folder where client libraries are to be stored. |
|
| 1009 | - * @param string $folder |
|
| 1010 | - */ |
|
| 1007 | + /** |
|
| 1008 | + * Sets the folder where client libraries are to be stored. |
|
| 1009 | + * @param string $folder |
|
| 1010 | + */ |
|
| 1011 | 1011 | public static function setClientLibrariesFolder(string $folder) |
| 1012 | 1012 | { |
| 1013 | 1013 | self::$clientFolder = $folder; |
| 1014 | 1014 | } |
| 1015 | 1015 | |
| 1016 | - /** |
|
| 1017 | - * Retrieves the path to the folder in which the client |
|
| 1018 | - * libraries should be stored. |
|
| 1019 | - * |
|
| 1020 | - * NOTE: Can return an empty string, when this is disabled. |
|
| 1021 | - * |
|
| 1022 | - * @return string |
|
| 1023 | - */ |
|
| 1016 | + /** |
|
| 1017 | + * Retrieves the path to the folder in which the client |
|
| 1018 | + * libraries should be stored. |
|
| 1019 | + * |
|
| 1020 | + * NOTE: Can return an empty string, when this is disabled. |
|
| 1021 | + * |
|
| 1022 | + * @return string |
|
| 1023 | + */ |
|
| 1024 | 1024 | public static function getClientLibrariesFolder() : string |
| 1025 | 1025 | { |
| 1026 | 1026 | return self::$clientFolder; |
| 1027 | 1027 | } |
| 1028 | 1028 | |
| 1029 | - /** |
|
| 1030 | - * Writes / updates the client library files on disk, |
|
| 1031 | - * at the location specified in the {@link Localization::configure()} |
|
| 1032 | - * method. |
|
| 1033 | - * |
|
| 1034 | - * @see Localization_ClientGenerator |
|
| 1035 | - * @param bool $force Whether to refresh the files, even if they exist. |
|
| 1036 | - */ |
|
| 1029 | + /** |
|
| 1030 | + * Writes / updates the client library files on disk, |
|
| 1031 | + * at the location specified in the {@link Localization::configure()} |
|
| 1032 | + * method. |
|
| 1033 | + * |
|
| 1034 | + * @see Localization_ClientGenerator |
|
| 1035 | + * @param bool $force Whether to refresh the files, even if they exist. |
|
| 1036 | + */ |
|
| 1037 | 1037 | public static function writeClientFiles(bool $force=false) : void |
| 1038 | 1038 | { |
| 1039 | 1039 | self::createGenerator()->writeFiles($force); |
| 1040 | 1040 | } |
| 1041 | 1041 | |
| 1042 | - /** |
|
| 1043 | - * Creates a new instance of the client generator class |
|
| 1044 | - * that is used to write the localization files into the |
|
| 1045 | - * target folder on disk. |
|
| 1046 | - * |
|
| 1047 | - * @return Localization_ClientGenerator |
|
| 1048 | - */ |
|
| 1042 | + /** |
|
| 1043 | + * Creates a new instance of the client generator class |
|
| 1044 | + * that is used to write the localization files into the |
|
| 1045 | + * target folder on disk. |
|
| 1046 | + * |
|
| 1047 | + * @return Localization_ClientGenerator |
|
| 1048 | + */ |
|
| 1049 | 1049 | public static function createGenerator() : Localization_ClientGenerator |
| 1050 | 1050 | { |
| 1051 | 1051 | return new Localization_ClientGenerator(); |
@@ -1088,13 +1088,13 @@ discard block |
||
| 1088 | 1088 | } |
| 1089 | 1089 | } |
| 1090 | 1090 | |
| 1091 | - /** |
|
| 1092 | - * Creates the editor instance that can be used to |
|
| 1093 | - * display the localization UI to edit translateable |
|
| 1094 | - * strings in the browser. |
|
| 1095 | - * |
|
| 1096 | - * @return \AppLocalize\Localization_Editor |
|
| 1097 | - */ |
|
| 1091 | + /** |
|
| 1092 | + * Creates the editor instance that can be used to |
|
| 1093 | + * display the localization UI to edit translateable |
|
| 1094 | + * strings in the browser. |
|
| 1095 | + * |
|
| 1096 | + * @return \AppLocalize\Localization_Editor |
|
| 1097 | + */ |
|
| 1098 | 1098 | public static function createEditor() : Localization_Editor |
| 1099 | 1099 | { |
| 1100 | 1100 | self::requireConfiguration(); |
@@ -1102,10 +1102,10 @@ discard block |
||
| 1102 | 1102 | return new Localization_Editor(); |
| 1103 | 1103 | } |
| 1104 | 1104 | |
| 1105 | - /** |
|
| 1106 | - * Retrieves a list of all available source IDs. |
|
| 1107 | - * @return string[] |
|
| 1108 | - */ |
|
| 1105 | + /** |
|
| 1106 | + * Retrieves a list of all available source IDs. |
|
| 1107 | + * @return string[] |
|
| 1108 | + */ |
|
| 1109 | 1109 | public static function getSourceIDs() |
| 1110 | 1110 | { |
| 1111 | 1111 | $ids = array(); |
@@ -1132,9 +1132,9 @@ discard block |
||
| 1132 | 1132 | return $aliases; |
| 1133 | 1133 | } |
| 1134 | 1134 | |
| 1135 | - /** |
|
| 1136 | - * Resets all locales to the built-in locale. |
|
| 1137 | - */ |
|
| 1135 | + /** |
|
| 1136 | + * Resets all locales to the built-in locale. |
|
| 1137 | + */ |
|
| 1138 | 1138 | public static function reset() : void |
| 1139 | 1139 | { |
| 1140 | 1140 | self::$locales = array(); |
@@ -1166,22 +1166,22 @@ discard block |
||
| 1166 | 1166 | 'de_CH' |
| 1167 | 1167 | ); |
| 1168 | 1168 | |
| 1169 | - /** |
|
| 1170 | - * Retrieves a list of all supported locales. |
|
| 1171 | - * |
|
| 1172 | - * @return array |
|
| 1173 | - */ |
|
| 1169 | + /** |
|
| 1170 | + * Retrieves a list of all supported locales. |
|
| 1171 | + * |
|
| 1172 | + * @return array |
|
| 1173 | + */ |
|
| 1174 | 1174 | public static function getSupportedLocaleNames() : array |
| 1175 | 1175 | { |
| 1176 | 1176 | return self::$supportedLocales; |
| 1177 | 1177 | } |
| 1178 | 1178 | |
| 1179 | - /** |
|
| 1180 | - * Checks whether the specified locale is supported. |
|
| 1181 | - * |
|
| 1182 | - * @param string $localeName |
|
| 1183 | - * @return bool |
|
| 1184 | - */ |
|
| 1179 | + /** |
|
| 1180 | + * Checks whether the specified locale is supported. |
|
| 1181 | + * |
|
| 1182 | + * @param string $localeName |
|
| 1183 | + * @return bool |
|
| 1184 | + */ |
|
| 1185 | 1185 | public static function isLocaleSupported(string $localeName) : bool |
| 1186 | 1186 | { |
| 1187 | 1187 | return in_array($localeName, self::$supportedLocales); |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | */ |
| 120 | 120 | public static function init() : void |
| 121 | 121 | { |
| 122 | - if(self::$initDone) { |
|
| 122 | + if (self::$initDone) { |
|
| 123 | 123 | return; |
| 124 | 124 | } |
| 125 | 125 | |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | */ |
| 164 | 164 | public static function getLocalesByNS(string $namespace) |
| 165 | 165 | { |
| 166 | - if(isset(self::$locales[$namespace])) { |
|
| 166 | + if (isset(self::$locales[$namespace])) { |
|
| 167 | 167 | return array_values(self::$locales[$namespace]); |
| 168 | 168 | } |
| 169 | 169 | |
@@ -208,11 +208,11 @@ discard block |
||
| 208 | 208 | */ |
| 209 | 209 | public static function addLocaleByNS(string $localeName, string $namespace) : Localization_Locale |
| 210 | 210 | { |
| 211 | - if(!isset(self::$locales[$namespace])) { |
|
| 211 | + if (!isset(self::$locales[$namespace])) { |
|
| 212 | 212 | self::$locales[$namespace] = array(); |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - if(!isset(self::$locales[$namespace][$localeName])) |
|
| 215 | + if (!isset(self::$locales[$namespace][$localeName])) |
|
| 216 | 216 | { |
| 217 | 217 | self::$locales[$namespace][$localeName] = self::createLocale($localeName); |
| 218 | 218 | |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | */ |
| 244 | 244 | public static function createCountry(string $id) |
| 245 | 245 | { |
| 246 | - $className = '\AppLocalize\Localization_Country_' . strtoupper($id); |
|
| 246 | + $className = '\AppLocalize\Localization_Country_'.strtoupper($id); |
|
| 247 | 247 | return new $className(); |
| 248 | 248 | } |
| 249 | 249 | |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | { |
| 336 | 336 | self::requireNamespace($namespace); |
| 337 | 337 | |
| 338 | - if(isset(self::$selected[$namespace])) { |
|
| 338 | + if (isset(self::$selected[$namespace])) { |
|
| 339 | 339 | return self::$selected[$namespace][$key]; |
| 340 | 340 | } |
| 341 | 341 | |
@@ -371,9 +371,9 @@ discard block |
||
| 371 | 371 | $locale = self::addLocaleByNS($localeName, $namespace); |
| 372 | 372 | $previous = null; |
| 373 | 373 | |
| 374 | - if(isset(self::$selected[$namespace])) |
|
| 374 | + if (isset(self::$selected[$namespace])) |
|
| 375 | 375 | { |
| 376 | - if(self::$selected[$namespace]['name'] === $localeName) { |
|
| 376 | + if (self::$selected[$namespace]['name'] === $localeName) { |
|
| 377 | 377 | return $locale; |
| 378 | 378 | } |
| 379 | 379 | |
@@ -411,11 +411,11 @@ discard block |
||
| 411 | 411 | $class = '\AppLocalize\Localization_Event_'.$name; |
| 412 | 412 | $event = new $class($argsList); |
| 413 | 413 | |
| 414 | - if(!isset(self::$listeners[$name])) { |
|
| 414 | + if (!isset(self::$listeners[$name])) { |
|
| 415 | 415 | return $event; |
| 416 | 416 | } |
| 417 | 417 | |
| 418 | - foreach(self::$listeners[$name] as $listener) |
|
| 418 | + foreach (self::$listeners[$name] as $listener) |
|
| 419 | 419 | { |
| 420 | 420 | $callArgs = $listener['args']; |
| 421 | 421 | array_unshift($callArgs, $event); |
@@ -434,15 +434,15 @@ discard block |
||
| 434 | 434 | * @param array $args Additional arguments to add to the event |
| 435 | 435 | * @return int The listener number. |
| 436 | 436 | */ |
| 437 | - public static function addEventListener(string $eventName, $callback, array $args=array()) : int |
|
| 437 | + public static function addEventListener(string $eventName, $callback, array $args = array()) : int |
|
| 438 | 438 | { |
| 439 | - if(!isset(self::$listeners[$eventName])) { |
|
| 439 | + if (!isset(self::$listeners[$eventName])) { |
|
| 440 | 440 | self::$listeners[$eventName] = array(); |
| 441 | 441 | } |
| 442 | 442 | |
| 443 | 443 | $className = '\AppLocalize\Localization_Event_'.$eventName; |
| 444 | 444 | |
| 445 | - if(!class_exists($className)) |
|
| 445 | + if (!class_exists($className)) |
|
| 446 | 446 | { |
| 447 | 447 | throw new Localization_Exception( |
| 448 | 448 | sprintf('Unknown localization event [%s].', $eventName), |
@@ -475,7 +475,7 @@ discard block |
||
| 475 | 475 | * @return int |
| 476 | 476 | * @see Localization_Event_LocaleChanged |
| 477 | 477 | */ |
| 478 | - public static function onLocaleChanged($callback, array $args=array()) : int |
|
| 478 | + public static function onLocaleChanged($callback, array $args = array()) : int |
|
| 479 | 479 | { |
| 480 | 480 | return self::addEventListener('LocaleChanged', $callback, $args); |
| 481 | 481 | } |
@@ -599,7 +599,7 @@ discard block |
||
| 599 | 599 | { |
| 600 | 600 | self::requireNamespace($namespace); |
| 601 | 601 | |
| 602 | - if(isset(self::$locales[$namespace]) && isset(self::$locales[$namespace][$localeName])) { |
|
| 602 | + if (isset(self::$locales[$namespace]) && isset(self::$locales[$namespace][$localeName])) { |
|
| 603 | 603 | return self::$locales[$namespace][$localeName]; |
| 604 | 604 | } |
| 605 | 605 | |
@@ -666,9 +666,9 @@ discard block |
||
| 666 | 666 | /** |
| 667 | 667 | * @return Localization_Translator |
| 668 | 668 | */ |
| 669 | - public static function getTranslator(Localization_Locale $locale=null) : Localization_Translator |
|
| 669 | + public static function getTranslator(Localization_Locale $locale = null) : Localization_Translator |
|
| 670 | 670 | { |
| 671 | - if($locale !== null) |
|
| 671 | + if ($locale !== null) |
|
| 672 | 672 | { |
| 673 | 673 | $obj = new Localization_Translator(); |
| 674 | 674 | $obj->addSources(self::getSources()); |
@@ -676,7 +676,7 @@ discard block |
||
| 676 | 676 | return $obj; |
| 677 | 677 | } |
| 678 | 678 | |
| 679 | - if(!isset(self::$translator)) |
|
| 679 | + if (!isset(self::$translator)) |
|
| 680 | 680 | { |
| 681 | 681 | $obj = new Localization_Translator(); |
| 682 | 682 | $obj->addSources(self::getSources()); |
@@ -701,7 +701,7 @@ discard block |
||
| 701 | 701 | { |
| 702 | 702 | self::requireNamespace($namespace); |
| 703 | 703 | |
| 704 | - if(isset(self::$locales[$namespace])) { |
|
| 704 | + if (isset(self::$locales[$namespace])) { |
|
| 705 | 705 | return count(self::$locales[$namespace]); |
| 706 | 706 | } |
| 707 | 707 | |
@@ -710,7 +710,7 @@ discard block |
||
| 710 | 710 | |
| 711 | 711 | protected static function requireNamespace(string $namespace) |
| 712 | 712 | { |
| 713 | - if(isset(self::$locales[$namespace])) { |
|
| 713 | + if (isset(self::$locales[$namespace])) { |
|
| 714 | 714 | return; |
| 715 | 715 | } |
| 716 | 716 | |
@@ -733,7 +733,7 @@ discard block |
||
| 733 | 733 | * @param string $label |
| 734 | 734 | * @return \HTML_QuickForm2_Element_Select |
| 735 | 735 | */ |
| 736 | - public static function injectContentLocalesSelector(string $elementName, \HTML_QuickForm2_Container $container, string $label='') : \HTML_QuickForm2_Element_Select |
|
| 736 | + public static function injectContentLocalesSelector(string $elementName, \HTML_QuickForm2_Container $container, string $label = '') : \HTML_QuickForm2_Element_Select |
|
| 737 | 737 | { |
| 738 | 738 | return self::injectLocalesSelectorNS($elementName, self::NAMESPACE_CONTENT, $container, $label); |
| 739 | 739 | } |
@@ -747,7 +747,7 @@ discard block |
||
| 747 | 747 | * @param string $label |
| 748 | 748 | * @return \HTML_QuickForm2_Element_Select |
| 749 | 749 | */ |
| 750 | - public static function injectAppLocalesSelector(string $elementName, \HTML_QuickForm2_Container $container, string $label='') : \HTML_QuickForm2_Element_Select |
|
| 750 | + public static function injectAppLocalesSelector(string $elementName, \HTML_QuickForm2_Container $container, string $label = '') : \HTML_QuickForm2_Element_Select |
|
| 751 | 751 | { |
| 752 | 752 | return self::injectLocalesSelectorNS($elementName, self::NAMESPACE_APPLICATION, $container, $label); |
| 753 | 753 | } |
@@ -762,9 +762,9 @@ discard block |
||
| 762 | 762 | * @param \HTML_QuickForm2_Container $container |
| 763 | 763 | * @return \HTML_QuickForm2_Element_Select |
| 764 | 764 | */ |
| 765 | - public static function injectLocalesSelectorNS(string $elementName, string $namespace, \HTML_QuickForm2_Container $container, string $label='') : \HTML_QuickForm2_Element_Select |
|
| 765 | + public static function injectLocalesSelectorNS(string $elementName, string $namespace, \HTML_QuickForm2_Container $container, string $label = '') : \HTML_QuickForm2_Element_Select |
|
| 766 | 766 | { |
| 767 | - if(empty($label)) { |
|
| 767 | + if (empty($label)) { |
|
| 768 | 768 | $label = t('Language'); |
| 769 | 769 | } |
| 770 | 770 | |
@@ -774,7 +774,7 @@ discard block |
||
| 774 | 774 | |
| 775 | 775 | $locales = self::getLocalesByNS($namespace); |
| 776 | 776 | |
| 777 | - foreach($locales as $locale) { |
|
| 777 | + foreach ($locales as $locale) { |
|
| 778 | 778 | $select->addOption($locale->getLabel(), $locale->getName()); |
| 779 | 779 | } |
| 780 | 780 | |
@@ -808,14 +808,14 @@ discard block |
||
| 808 | 808 | |
| 809 | 809 | public static function addExcludeFolder(string $folderName) : void |
| 810 | 810 | { |
| 811 | - if(!in_array($folderName, self::$excludeFolders)) { |
|
| 811 | + if (!in_array($folderName, self::$excludeFolders)) { |
|
| 812 | 812 | self::$excludeFolders[] = $folderName; |
| 813 | 813 | } |
| 814 | 814 | } |
| 815 | 815 | |
| 816 | 816 | public static function addExcludeFile(string $fileName) : void |
| 817 | 817 | { |
| 818 | - if(!in_array($fileName, self::$excludeFiles)) { |
|
| 818 | + if (!in_array($fileName, self::$excludeFiles)) { |
|
| 819 | 819 | self::$excludeFiles[] = $fileName; |
| 820 | 820 | } |
| 821 | 821 | } |
@@ -842,11 +842,11 @@ discard block |
||
| 842 | 842 | |
| 843 | 843 | $grouped = array(); |
| 844 | 844 | |
| 845 | - foreach($sources as $source) |
|
| 845 | + foreach ($sources as $source) |
|
| 846 | 846 | { |
| 847 | 847 | $group = $source->getGroup(); |
| 848 | 848 | |
| 849 | - if(!isset($grouped[$group])) { |
|
| 849 | + if (!isset($grouped[$group])) { |
|
| 850 | 850 | $grouped[$group] = array(); |
| 851 | 851 | } |
| 852 | 852 | |
@@ -864,8 +864,8 @@ discard block |
||
| 864 | 864 | public static function sourceExists(string $sourceID) : bool |
| 865 | 865 | { |
| 866 | 866 | $sources = self::getSources(); |
| 867 | - foreach($sources as $source) { |
|
| 868 | - if($source->getID() == $sourceID) { |
|
| 867 | + foreach ($sources as $source) { |
|
| 868 | + if ($source->getID() == $sourceID) { |
|
| 869 | 869 | return true; |
| 870 | 870 | } |
| 871 | 871 | } |
@@ -881,8 +881,8 @@ discard block |
||
| 881 | 881 | public static function sourceAliasExists(string $sourceAlias) : bool |
| 882 | 882 | { |
| 883 | 883 | $sources = self::getSources(); |
| 884 | - foreach($sources as $source) { |
|
| 885 | - if($source->getAlias() == $sourceAlias) { |
|
| 884 | + foreach ($sources as $source) { |
|
| 885 | + if ($source->getAlias() == $sourceAlias) { |
|
| 886 | 886 | return true; |
| 887 | 887 | } |
| 888 | 888 | } |
@@ -900,8 +900,8 @@ discard block |
||
| 900 | 900 | public static function getSourceByID(string $sourceID) : Localization_Source |
| 901 | 901 | { |
| 902 | 902 | $sources = self::getSources(); |
| 903 | - foreach($sources as $source) { |
|
| 904 | - if($source->getID() == $sourceID) { |
|
| 903 | + foreach ($sources as $source) { |
|
| 904 | + if ($source->getID() == $sourceID) { |
|
| 905 | 905 | return $source; |
| 906 | 906 | } |
| 907 | 907 | } |
@@ -926,8 +926,8 @@ discard block |
||
| 926 | 926 | public static function getSourceByAlias(string $sourceAlias) : Localization_Source |
| 927 | 927 | { |
| 928 | 928 | $sources = self::getSources(); |
| 929 | - foreach($sources as $source) { |
|
| 930 | - if($source->getAlias() == $sourceAlias) { |
|
| 929 | + foreach ($sources as $source) { |
|
| 930 | + if ($source->getAlias() == $sourceAlias) { |
|
| 931 | 931 | return $source; |
| 932 | 932 | } |
| 933 | 933 | } |
@@ -968,7 +968,7 @@ discard block |
||
| 968 | 968 | * @param string $storageFile Where to store the file analysis storage file. |
| 969 | 969 | * @param string $clientLibrariesFolder Where to put the client libraries and translation files. Will be created if it does not exist. Optional: if not set, client libraries will not be created. |
| 970 | 970 | */ |
| 971 | - public static function configure(string $storageFile, string $clientLibrariesFolder='') |
|
| 971 | + public static function configure(string $storageFile, string $clientLibrariesFolder = '') |
|
| 972 | 972 | { |
| 973 | 973 | self::$configured = true; |
| 974 | 974 | |
@@ -977,7 +977,7 @@ discard block |
||
| 977 | 977 | |
| 978 | 978 | // only write the client libraries to disk if the folder |
| 979 | 979 | // has been specified. |
| 980 | - if(!empty($clientLibrariesFolder)) |
|
| 980 | + if (!empty($clientLibrariesFolder)) |
|
| 981 | 981 | { |
| 982 | 982 | self::writeClientFiles(); |
| 983 | 983 | } |
@@ -1034,7 +1034,7 @@ discard block |
||
| 1034 | 1034 | * @see Localization_ClientGenerator |
| 1035 | 1035 | * @param bool $force Whether to refresh the files, even if they exist. |
| 1036 | 1036 | */ |
| 1037 | - public static function writeClientFiles(bool $force=false) : void |
|
| 1037 | + public static function writeClientFiles(bool $force = false) : void |
|
| 1038 | 1038 | { |
| 1039 | 1039 | self::createGenerator()->writeFiles($force); |
| 1040 | 1040 | } |
@@ -1060,7 +1060,7 @@ discard block |
||
| 1060 | 1060 | |
| 1061 | 1061 | protected static function requireConfiguration() |
| 1062 | 1062 | { |
| 1063 | - if(!self::$configured) |
|
| 1063 | + if (!self::$configured) |
|
| 1064 | 1064 | { |
| 1065 | 1065 | throw new Localization_Exception( |
| 1066 | 1066 | 'The localization configuration is incomplete.', |
@@ -1069,7 +1069,7 @@ discard block |
||
| 1069 | 1069 | ); |
| 1070 | 1070 | } |
| 1071 | 1071 | |
| 1072 | - if(empty(self::$storageFile)) |
|
| 1072 | + if (empty(self::$storageFile)) |
|
| 1073 | 1073 | { |
| 1074 | 1074 | throw new Localization_Exception( |
| 1075 | 1075 | 'No localization storage file set', |
@@ -1078,7 +1078,7 @@ discard block |
||
| 1078 | 1078 | ); |
| 1079 | 1079 | } |
| 1080 | 1080 | |
| 1081 | - if(empty(self::$sources)) |
|
| 1081 | + if (empty(self::$sources)) |
|
| 1082 | 1082 | { |
| 1083 | 1083 | throw new Localization_Exception( |
| 1084 | 1084 | 'No source folders have been defined.', |
@@ -1110,7 +1110,7 @@ discard block |
||
| 1110 | 1110 | { |
| 1111 | 1111 | $ids = array(); |
| 1112 | 1112 | |
| 1113 | - foreach(self::$sources as $source) { |
|
| 1113 | + foreach (self::$sources as $source) { |
|
| 1114 | 1114 | $ids[] = $source->getID(); |
| 1115 | 1115 | } |
| 1116 | 1116 | |
@@ -1125,7 +1125,7 @@ discard block |
||
| 1125 | 1125 | { |
| 1126 | 1126 | $aliases = array(); |
| 1127 | 1127 | |
| 1128 | - foreach(self::$sources as $source) { |
|
| 1128 | + foreach (self::$sources as $source) { |
|
| 1129 | 1129 | $aliases[] = $source->getAlias(); |
| 1130 | 1130 | } |
| 1131 | 1131 | |
@@ -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 number |
|
| 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 number |
|
| 162 | + */ |
|
| 163 | 163 | public function callback_sortStrings(array $a, array $b) : int |
| 164 | 164 | { |
| 165 | 165 | $result = strnatcasecmp($a['text'], $b['text']); |
@@ -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.'; |
@@ -45,9 +45,9 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | private $targetLocaleName = null; |
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * @var Localization_Source[] |
|
| 50 | - */ |
|
| 48 | + /** |
|
| 49 | + * @var Localization_Source[] |
|
| 50 | + */ |
|
| 51 | 51 | private $sources = array(); |
| 52 | 52 | |
| 53 | 53 | public function addSource(Localization_Source $source) |
@@ -175,14 +175,14 @@ discard block |
||
| 175 | 175 | ); |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - /** |
|
| 179 | - * Retrieves all available strings for the specified locale, |
|
| 180 | - * as hash => text value pairs. |
|
| 181 | - * |
|
| 182 | - * @param Localization_Locale $locale |
|
| 183 | - * @throws Localization_Exception |
|
| 184 | - * @return string[] |
|
| 185 | - */ |
|
| 178 | + /** |
|
| 179 | + * Retrieves all available strings for the specified locale, |
|
| 180 | + * as hash => text value pairs. |
|
| 181 | + * |
|
| 182 | + * @param Localization_Locale $locale |
|
| 183 | + * @throws Localization_Exception |
|
| 184 | + * @return string[] |
|
| 185 | + */ |
|
| 186 | 186 | public function getStrings(Localization_Locale $locale) |
| 187 | 187 | { |
| 188 | 188 | $this->load($locale); |
@@ -211,14 +211,14 @@ discard block |
||
| 211 | 211 | return !empty($this->strings[$locale->getName()]); |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | - /** |
|
| 215 | - * @param string $type |
|
| 216 | - * @param Localization_Scanner_StringHash[] $hashes |
|
| 217 | - * @param string $file |
|
| 218 | - * @param Localization_Locale $locale |
|
| 219 | - * @param boolean $editable |
|
| 220 | - * @throws Localization_Exception |
|
| 221 | - */ |
|
| 214 | + /** |
|
| 215 | + * @param string $type |
|
| 216 | + * @param Localization_Scanner_StringHash[] $hashes |
|
| 217 | + * @param string $file |
|
| 218 | + * @param Localization_Locale $locale |
|
| 219 | + * @param boolean $editable |
|
| 220 | + * @throws Localization_Exception |
|
| 221 | + */ |
|
| 222 | 222 | protected function renderStringsFile($type, Localization_Source $source, $hashes, $file, Localization_Locale $locale, $editable=true) |
| 223 | 223 | { |
| 224 | 224 | $writer = new Localization_Writer($locale, $type, $file); |
@@ -265,13 +265,13 @@ discard block |
||
| 265 | 265 | ); |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | - /** |
|
| 269 | - * Retrieves the full path to the strings storage ini file |
|
| 270 | - * for the clientside strings. |
|
| 271 | - * |
|
| 272 | - * @param Localization_Locale $locale |
|
| 273 | - * @return string |
|
| 274 | - */ |
|
| 268 | + /** |
|
| 269 | + * Retrieves the full path to the strings storage ini file |
|
| 270 | + * for the clientside strings. |
|
| 271 | + * |
|
| 272 | + * @param Localization_Locale $locale |
|
| 273 | + * @return string |
|
| 274 | + */ |
|
| 275 | 275 | protected function getClientStorageFile(Localization_Locale $locale, Localization_Source $source) |
| 276 | 276 | { |
| 277 | 277 | return sprintf( |
@@ -393,12 +393,12 @@ discard block |
||
| 393 | 393 | return null; |
| 394 | 394 | } |
| 395 | 395 | |
| 396 | - /** |
|
| 397 | - * Retrieves only the strings that are available clientside. |
|
| 398 | - * |
|
| 399 | - * @param Localization_Locale $locale |
|
| 400 | - * @return array |
|
| 401 | - */ |
|
| 396 | + /** |
|
| 397 | + * Retrieves only the strings that are available clientside. |
|
| 398 | + * |
|
| 399 | + * @param Localization_Locale $locale |
|
| 400 | + * @return array |
|
| 401 | + */ |
|
| 402 | 402 | public function getClientStrings(Localization_Locale $locale) |
| 403 | 403 | { |
| 404 | 404 | $result = array(); |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | public function addSources($sources) |
| 59 | 59 | { |
| 60 | - foreach($sources as $source) { |
|
| 60 | + foreach ($sources as $source) { |
|
| 61 | 61 | $this->addSource($source); |
| 62 | 62 | } |
| 63 | 63 | } |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | $this->strings[$localeName] = array(); |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - foreach($this->sources as $source) |
|
| 111 | + foreach ($this->sources as $source) |
|
| 112 | 112 | { |
| 113 | 113 | $file = $this->resolveStorageFile($locale, $source); |
| 114 | 114 | if (!file_exists($file)) { |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | |
| 118 | 118 | $data = parse_ini_file($file, false); |
| 119 | 119 | |
| 120 | - if($data === false) |
|
| 120 | + if ($data === false) |
|
| 121 | 121 | { |
| 122 | 122 | throw new Localization_Exception( |
| 123 | 123 | 'Malformatted localization file', |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | |
| 190 | 190 | $name = $locale->getName(); |
| 191 | 191 | |
| 192 | - if(isset($this->strings[$name])) { |
|
| 192 | + if (isset($this->strings[$name])) { |
|
| 193 | 193 | return $this->strings[$name]; |
| 194 | 194 | } |
| 195 | 195 | |
@@ -219,11 +219,11 @@ discard block |
||
| 219 | 219 | * @param boolean $editable |
| 220 | 220 | * @throws Localization_Exception |
| 221 | 221 | */ |
| 222 | - protected function renderStringsFile($type, Localization_Source $source, $hashes, $file, Localization_Locale $locale, $editable=true) |
|
| 222 | + protected function renderStringsFile($type, Localization_Source $source, $hashes, $file, Localization_Locale $locale, $editable = true) |
|
| 223 | 223 | { |
| 224 | 224 | $writer = new Localization_Writer($locale, $type, $file); |
| 225 | 225 | |
| 226 | - if($editable) |
|
| 226 | + if ($editable) |
|
| 227 | 227 | { |
| 228 | 228 | $writer->makeEditable(); |
| 229 | 229 | } |
@@ -232,14 +232,14 @@ discard block |
||
| 232 | 232 | |
| 233 | 233 | foreach ($hashes as $hash) |
| 234 | 234 | { |
| 235 | - if(!$hash->hasSourceID($sourceID)) { |
|
| 235 | + if (!$hash->hasSourceID($sourceID)) { |
|
| 236 | 236 | continue; |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | $text = $this->getHashTranslation($hash->getHash(), $locale); |
| 240 | 240 | |
| 241 | 241 | // skip any empty strings |
| 242 | - if($text === null || trim($text) == '') { |
|
| 242 | + if ($text === null || trim($text) == '') { |
|
| 243 | 243 | continue; |
| 244 | 244 | } |
| 245 | 245 | |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | |
| 318 | 318 | // to avoid re-creating the hash for the same texts over and over, |
| 319 | 319 | // we keep track of the hashes we created, and re-use them. |
| 320 | - if(isset($this->reverseStrings[$text])) { |
|
| 320 | + if (isset($this->reverseStrings[$text])) { |
|
| 321 | 321 | $hash = $this->reverseStrings[$text]; |
| 322 | 322 | } else { |
| 323 | 323 | $hash = md5($text); |
@@ -378,15 +378,15 @@ discard block |
||
| 378 | 378 | * @param string $hash |
| 379 | 379 | * @return string|NULL |
| 380 | 380 | */ |
| 381 | - public function getHashTranslation($hash, Localization_Locale $locale=null) |
|
| 381 | + public function getHashTranslation($hash, Localization_Locale $locale = null) |
|
| 382 | 382 | { |
| 383 | - if(!$locale) { |
|
| 383 | + if (!$locale) { |
|
| 384 | 384 | $locale = $this->targetLocale; |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | 387 | $localeName = $locale->getName(); |
| 388 | 388 | |
| 389 | - if(isset($this->strings[$localeName]) && isset($this->strings[$localeName][$hash])) { |
|
| 389 | + if (isset($this->strings[$localeName]) && isset($this->strings[$localeName][$hash])) { |
|
| 390 | 390 | return $this->strings[$localeName][$hash]; |
| 391 | 391 | } |
| 392 | 392 | |
@@ -403,10 +403,10 @@ discard block |
||
| 403 | 403 | { |
| 404 | 404 | $result = array(); |
| 405 | 405 | |
| 406 | - foreach($this->sources as $source) |
|
| 406 | + foreach ($this->sources as $source) |
|
| 407 | 407 | { |
| 408 | 408 | $localeFile = self::getClientStorageFile($locale, $source); |
| 409 | - if(!file_exists($localeFile)) { |
|
| 409 | + if (!file_exists($localeFile)) { |
|
| 410 | 410 | continue; |
| 411 | 411 | } |
| 412 | 412 | |