@@ -13,7 +13,7 @@ |
||
| 13 | 13 | $autoload = realpath($root.'/../vendor/autoload.php'); |
| 14 | 14 | |
| 15 | 15 | // we need the autoloader to be present |
| 16 | - if(!file_exists($autoload)) { |
|
| 16 | + if (!file_exists($autoload)) { |
|
| 17 | 17 | die('<b>ERROR:</b> Autoloader not present. Run composer update first.'); |
| 18 | 18 | } |
| 19 | 19 | |
@@ -9,12 +9,12 @@ |
||
| 9 | 9 | protected function parseDefinition() : void |
| 10 | 10 | { |
| 11 | 11 | // some entries are strings, like parenthesises, semicolons and the like. |
| 12 | - if(is_string($this->definition)) |
|
| 12 | + if (is_string($this->definition)) |
|
| 13 | 13 | { |
| 14 | 14 | $this->token = $this->definition; |
| 15 | 15 | $this->value = null; |
| 16 | 16 | |
| 17 | - if(isset($this->parentToken)) { |
|
| 17 | + if (isset($this->parentToken)) { |
|
| 18 | 18 | $this->line = $this->parentToken->getLine(); |
| 19 | 19 | } |
| 20 | 20 | } |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | return self::$instances[$id]; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - $className = '\AppLocalize\Localization_Currency_' . $id; |
|
| 55 | + $className = '\AppLocalize\Localization_Currency_'.$id; |
|
| 56 | 56 | |
| 57 | 57 | return new $className($country); |
| 58 | 58 | } |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | public static function isCurrencyKnown($currencyName) |
| 94 | 94 | { |
| 95 | - return file_exists(__DIR__ . '/Currency/' . $currencyName . '.php'); |
|
| 95 | + return file_exists(__DIR__.'/Currency/'.$currencyName.'.php'); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | return $this->country->getNumberDecimalsSeparator(); |
| 269 | 269 | } |
| 270 | 270 | |
| 271 | - public function makeReadable($number, $decimalPositions = 2, $addSymbol=true) |
|
| 271 | + public function makeReadable($number, $decimalPositions = 2, $addSymbol = true) |
|
| 272 | 272 | { |
| 273 | 273 | if ($number == null || $number == '') { |
| 274 | 274 | return null; |
@@ -287,14 +287,14 @@ discard block |
||
| 287 | 287 | |
| 288 | 288 | $number = $this->formatNumber($parsed->getFloat(), $decimalPositions); |
| 289 | 289 | |
| 290 | - if(!$addSymbol) { |
|
| 290 | + if (!$addSymbol) { |
|
| 291 | 291 | return $number; |
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | if ($this->isSymbolOnFront()) { |
| 295 | - return $this->getSymbol() . ' ' . $number; |
|
| 295 | + return $this->getSymbol().' '.$number; |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | - return $number . ' ' . $this->getSymbol(); |
|
| 298 | + return $number.' '.$this->getSymbol(); |
|
| 299 | 299 | } |
| 300 | 300 | } |
| 301 | 301 | \ 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; |
@@ -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"; |
@@ -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 | |
@@ -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 | } |
@@ -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 | |