@@ -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 | |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | $autoload = realpath($root.'/../vendor/autoload.php'); |
| 13 | 13 | |
| 14 | 14 | // we need the autoloader to be present |
| 15 | - if(!file_exists($autoload)) { |
|
| 15 | + if (!file_exists($autoload)) { |
|
| 16 | 16 | die('<b>ERROR:</b> Autoloader not present. Run composer update first.'); |
| 17 | 17 | } |
| 18 | 18 | |
@@ -3,7 +3,7 @@ |
||
| 3 | 3 | $text = t('This text is in the global scope.'); |
| 4 | 4 | |
| 5 | 5 | $text2 = t( |
| 6 | - 'It is possible to write long texts ' . |
|
| 7 | - 'using text concatenation in the source ' . |
|
| 6 | + 'It is possible to write long texts '. |
|
| 7 | + 'using text concatenation in the source '. |
|
| 8 | 8 | 'code to keep it readable.' |
| 9 | 9 | ); |
| 10 | 10 | \ No newline at end of file |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | */ |
| 115 | 115 | public static function init() |
| 116 | 116 | { |
| 117 | - if(self::$initDone) { |
|
| 117 | + if (self::$initDone) { |
|
| 118 | 118 | return; |
| 119 | 119 | } |
| 120 | 120 | |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | */ |
| 159 | 159 | public static function getLocalesByNS(string $namespace) |
| 160 | 160 | { |
| 161 | - if(isset(self::$locales[$namespace])) { |
|
| 161 | + if (isset(self::$locales[$namespace])) { |
|
| 162 | 162 | return array_values(self::$locales[$namespace]); |
| 163 | 163 | } |
| 164 | 164 | |
@@ -203,11 +203,11 @@ discard block |
||
| 203 | 203 | */ |
| 204 | 204 | public static function addLocaleByNS(string $localeName, string $namespace) : Localization_Locale |
| 205 | 205 | { |
| 206 | - if(!isset(self::$locales[$namespace])) { |
|
| 206 | + if (!isset(self::$locales[$namespace])) { |
|
| 207 | 207 | self::$locales[$namespace] = array(); |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | - if(!isset(self::$locales[$namespace][$localeName])) |
|
| 210 | + if (!isset(self::$locales[$namespace][$localeName])) |
|
| 211 | 211 | { |
| 212 | 212 | self::$locales[$namespace][$localeName] = self::createLocale($localeName); |
| 213 | 213 | |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | */ |
| 239 | 239 | public static function createCountry(string $id) |
| 240 | 240 | { |
| 241 | - $className = '\AppLocalize\Localization_Country_' . strtoupper($id); |
|
| 241 | + $className = '\AppLocalize\Localization_Country_'.strtoupper($id); |
|
| 242 | 242 | return new $className(); |
| 243 | 243 | } |
| 244 | 244 | |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | { |
| 331 | 331 | self::requireNamespace($namespace); |
| 332 | 332 | |
| 333 | - if(isset(self::$selected[$namespace])) { |
|
| 333 | + if (isset(self::$selected[$namespace])) { |
|
| 334 | 334 | return self::$selected[$namespace][$key]; |
| 335 | 335 | } |
| 336 | 336 | |
@@ -366,9 +366,9 @@ discard block |
||
| 366 | 366 | $locale = self::addLocaleByNS($localeName, $namespace); |
| 367 | 367 | $previous = null; |
| 368 | 368 | |
| 369 | - if(isset(self::$selected[$namespace])) |
|
| 369 | + if (isset(self::$selected[$namespace])) |
|
| 370 | 370 | { |
| 371 | - if(self::$selected[$namespace]['name'] === $localeName) { |
|
| 371 | + if (self::$selected[$namespace]['name'] === $localeName) { |
|
| 372 | 372 | return $locale; |
| 373 | 373 | } |
| 374 | 374 | |
@@ -406,11 +406,11 @@ discard block |
||
| 406 | 406 | $class = '\AppLocalize\Localization_Event_'.$name; |
| 407 | 407 | $event = new $class($argsList); |
| 408 | 408 | |
| 409 | - if(!isset(self::$listeners[$name])) { |
|
| 409 | + if (!isset(self::$listeners[$name])) { |
|
| 410 | 410 | return $event; |
| 411 | 411 | } |
| 412 | 412 | |
| 413 | - foreach(self::$listeners[$name] as $listener) |
|
| 413 | + foreach (self::$listeners[$name] as $listener) |
|
| 414 | 414 | { |
| 415 | 415 | $callArgs = $listener['args']; |
| 416 | 416 | array_unshift($callArgs, $event); |
@@ -429,15 +429,15 @@ discard block |
||
| 429 | 429 | * @param array $args Additional arguments to add to the event |
| 430 | 430 | * @return int The listener number. |
| 431 | 431 | */ |
| 432 | - public static function addEventListener(string $eventName, $callback, array $args=array()) : int |
|
| 432 | + public static function addEventListener(string $eventName, $callback, array $args = array()) : int |
|
| 433 | 433 | { |
| 434 | - if(!isset(self::$listeners[$eventName])) { |
|
| 434 | + if (!isset(self::$listeners[$eventName])) { |
|
| 435 | 435 | self::$listeners[$eventName] = array(); |
| 436 | 436 | } |
| 437 | 437 | |
| 438 | 438 | $className = '\AppLocalize\Localization_Event_'.$eventName; |
| 439 | 439 | |
| 440 | - if(!class_exists($className)) |
|
| 440 | + if (!class_exists($className)) |
|
| 441 | 441 | { |
| 442 | 442 | throw new Localization_Exception( |
| 443 | 443 | sprintf('Unknown localization event [%s].', $eventName), |
@@ -470,7 +470,7 @@ discard block |
||
| 470 | 470 | * @return int |
| 471 | 471 | * @see Localization_Event_LocaleChanged |
| 472 | 472 | */ |
| 473 | - public static function onLocaleChanged($callback, array $args=array()) : int |
|
| 473 | + public static function onLocaleChanged($callback, array $args = array()) : int |
|
| 474 | 474 | { |
| 475 | 475 | return self::addEventListener('LocaleChanged', $callback, $args); |
| 476 | 476 | } |
@@ -594,7 +594,7 @@ discard block |
||
| 594 | 594 | { |
| 595 | 595 | self::requireNamespace($namespace); |
| 596 | 596 | |
| 597 | - if(isset(self::$locales[$namespace]) && isset(self::$locales[$namespace][$localeName])) { |
|
| 597 | + if (isset(self::$locales[$namespace]) && isset(self::$locales[$namespace][$localeName])) { |
|
| 598 | 598 | return self::$locales[$namespace][$localeName]; |
| 599 | 599 | } |
| 600 | 600 | |
@@ -663,9 +663,9 @@ discard block |
||
| 663 | 663 | /** |
| 664 | 664 | * @return Localization_Translator |
| 665 | 665 | */ |
| 666 | - public static function getTranslator(Localization_Locale $locale=null) : Localization_Translator |
|
| 666 | + public static function getTranslator(Localization_Locale $locale = null) : Localization_Translator |
|
| 667 | 667 | { |
| 668 | - if($locale !== null) |
|
| 668 | + if ($locale !== null) |
|
| 669 | 669 | { |
| 670 | 670 | $obj = new Localization_Translator(); |
| 671 | 671 | $obj->addSources(self::getSources()); |
@@ -673,7 +673,7 @@ discard block |
||
| 673 | 673 | return $obj; |
| 674 | 674 | } |
| 675 | 675 | |
| 676 | - if(!isset(self::$translator)) |
|
| 676 | + if (!isset(self::$translator)) |
|
| 677 | 677 | { |
| 678 | 678 | $obj = new Localization_Translator(); |
| 679 | 679 | $obj->addSources(self::getSources()); |
@@ -698,14 +698,14 @@ discard block |
||
| 698 | 698 | { |
| 699 | 699 | self::requireNamespace($namespace); |
| 700 | 700 | |
| 701 | - if(isset(self::$locales[$namespace])) { |
|
| 701 | + if (isset(self::$locales[$namespace])) { |
|
| 702 | 702 | return count(self::$locales[$namespace]); |
| 703 | 703 | } |
| 704 | 704 | } |
| 705 | 705 | |
| 706 | 706 | protected static function requireNamespace(string $namespace) |
| 707 | 707 | { |
| 708 | - if(isset(self::$locales[$namespace])) { |
|
| 708 | + if (isset(self::$locales[$namespace])) { |
|
| 709 | 709 | return; |
| 710 | 710 | } |
| 711 | 711 | |
@@ -728,7 +728,7 @@ discard block |
||
| 728 | 728 | * @param string $label |
| 729 | 729 | * @return \HTML_QuickForm2_Element_Select |
| 730 | 730 | */ |
| 731 | - public static function injectContentLocalesSelector(string $elementName, \HTML_QuickForm2_Container $container, string $label='') : \HTML_QuickForm2_Element_Select |
|
| 731 | + public static function injectContentLocalesSelector(string $elementName, \HTML_QuickForm2_Container $container, string $label = '') : \HTML_QuickForm2_Element_Select |
|
| 732 | 732 | { |
| 733 | 733 | return self::injectLocalesSelectorNS($elementName, self::NAMESPACE_CONTENT, $container, $label); |
| 734 | 734 | } |
@@ -742,7 +742,7 @@ discard block |
||
| 742 | 742 | * @param string|NULL $label |
| 743 | 743 | * @return \HTML_QuickForm2_Element_Select |
| 744 | 744 | */ |
| 745 | - public static function injectAppLocalesSelector(string $elementName, \HTML_QuickForm2_Container $container, string $label='') : \HTML_QuickForm2_Element_Select |
|
| 745 | + public static function injectAppLocalesSelector(string $elementName, \HTML_QuickForm2_Container $container, string $label = '') : \HTML_QuickForm2_Element_Select |
|
| 746 | 746 | { |
| 747 | 747 | return self::injectLocalesSelectorNS($elementName, self::NAMESPACE_APPLICATION, $container, $label); |
| 748 | 748 | } |
@@ -757,9 +757,9 @@ discard block |
||
| 757 | 757 | * @param \HTML_QuickForm2_Container $container |
| 758 | 758 | * @return \HTML_QuickForm2_Element_Select |
| 759 | 759 | */ |
| 760 | - public static function injectLocalesSelectorNS(string $elementName, string $namespace, \HTML_QuickForm2_Container $container, string $label='') : \HTML_QuickForm2_Element_Select |
|
| 760 | + public static function injectLocalesSelectorNS(string $elementName, string $namespace, \HTML_QuickForm2_Container $container, string $label = '') : \HTML_QuickForm2_Element_Select |
|
| 761 | 761 | { |
| 762 | - if(empty($label)) { |
|
| 762 | + if (empty($label)) { |
|
| 763 | 763 | $label = t('Language'); |
| 764 | 764 | } |
| 765 | 765 | |
@@ -769,7 +769,7 @@ discard block |
||
| 769 | 769 | |
| 770 | 770 | $locales = self::getLocalesByNS($namespace); |
| 771 | 771 | |
| 772 | - foreach($locales as $locale) { |
|
| 772 | + foreach ($locales as $locale) { |
|
| 773 | 773 | $select->addOption($locale->getLabel(), $locale->getName()); |
| 774 | 774 | } |
| 775 | 775 | |
@@ -803,14 +803,14 @@ discard block |
||
| 803 | 803 | |
| 804 | 804 | public static function addExcludeFolder(string $folderName) : void |
| 805 | 805 | { |
| 806 | - if(!in_array($folderName, self::$excludeFolders)) { |
|
| 806 | + if (!in_array($folderName, self::$excludeFolders)) { |
|
| 807 | 807 | self::$excludeFolders[] = $folderName; |
| 808 | 808 | } |
| 809 | 809 | } |
| 810 | 810 | |
| 811 | 811 | public static function addExcludeFile(string $fileName) : void |
| 812 | 812 | { |
| 813 | - if(!in_array($fileName, self::$excludeFiles)) { |
|
| 813 | + if (!in_array($fileName, self::$excludeFiles)) { |
|
| 814 | 814 | self::$excludeFiles[] = $fileName; |
| 815 | 815 | } |
| 816 | 816 | } |
@@ -837,11 +837,11 @@ discard block |
||
| 837 | 837 | |
| 838 | 838 | $grouped = array(); |
| 839 | 839 | |
| 840 | - foreach($sources as $source) |
|
| 840 | + foreach ($sources as $source) |
|
| 841 | 841 | { |
| 842 | 842 | $group = $source->getGroup(); |
| 843 | 843 | |
| 844 | - if(!isset($grouped[$group])) { |
|
| 844 | + if (!isset($grouped[$group])) { |
|
| 845 | 845 | $grouped[$group] = array(); |
| 846 | 846 | } |
| 847 | 847 | |
@@ -859,8 +859,8 @@ discard block |
||
| 859 | 859 | public static function sourceExists(string $sourceID) : bool |
| 860 | 860 | { |
| 861 | 861 | $sources = self::getSources(); |
| 862 | - foreach($sources as $source) { |
|
| 863 | - if($source->getID() == $sourceID) { |
|
| 862 | + foreach ($sources as $source) { |
|
| 863 | + if ($source->getID() == $sourceID) { |
|
| 864 | 864 | return true; |
| 865 | 865 | } |
| 866 | 866 | } |
@@ -876,8 +876,8 @@ discard block |
||
| 876 | 876 | public static function sourceAliasExists(string $sourceAlias) : bool |
| 877 | 877 | { |
| 878 | 878 | $sources = self::getSources(); |
| 879 | - foreach($sources as $source) { |
|
| 880 | - if($source->getAlias() == $sourceAlias) { |
|
| 879 | + foreach ($sources as $source) { |
|
| 880 | + if ($source->getAlias() == $sourceAlias) { |
|
| 881 | 881 | return true; |
| 882 | 882 | } |
| 883 | 883 | } |
@@ -895,8 +895,8 @@ discard block |
||
| 895 | 895 | public static function getSourceByID(string $sourceID) : Localization_Source |
| 896 | 896 | { |
| 897 | 897 | $sources = self::getSources(); |
| 898 | - foreach($sources as $source) { |
|
| 899 | - if($source->getID() == $sourceID) { |
|
| 898 | + foreach ($sources as $source) { |
|
| 899 | + if ($source->getID() == $sourceID) { |
|
| 900 | 900 | return $source; |
| 901 | 901 | } |
| 902 | 902 | } |
@@ -921,8 +921,8 @@ discard block |
||
| 921 | 921 | public static function getSourceByAlias(string $sourceAlias) : Localization_Source |
| 922 | 922 | { |
| 923 | 923 | $sources = self::getSources(); |
| 924 | - foreach($sources as $source) { |
|
| 925 | - if($source->getAlias() == $sourceAlias) { |
|
| 924 | + foreach ($sources as $source) { |
|
| 925 | + if ($source->getAlias() == $sourceAlias) { |
|
| 926 | 926 | return $source; |
| 927 | 927 | } |
| 928 | 928 | } |
@@ -964,7 +964,7 @@ discard block |
||
| 964 | 964 | * @param string $storageFile Where to store the file analysis storage file. |
| 965 | 965 | * @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. |
| 966 | 966 | */ |
| 967 | - public static function configure(string $storageFile, string $clientLibrariesFolder='') |
|
| 967 | + public static function configure(string $storageFile, string $clientLibrariesFolder = '') |
|
| 968 | 968 | { |
| 969 | 969 | self::$configured = true; |
| 970 | 970 | |
@@ -973,7 +973,7 @@ discard block |
||
| 973 | 973 | |
| 974 | 974 | // only write the client libraries to disk if the folder |
| 975 | 975 | // has been specified. |
| 976 | - if(!empty($clientLibrariesFolder)) |
|
| 976 | + if (!empty($clientLibrariesFolder)) |
|
| 977 | 977 | { |
| 978 | 978 | self::writeClientFiles(); |
| 979 | 979 | } |
@@ -1030,7 +1030,7 @@ discard block |
||
| 1030 | 1030 | * @see Localization_ClientGenerator |
| 1031 | 1031 | * @param bool $force Whether to refresh the files, even if they exist. |
| 1032 | 1032 | */ |
| 1033 | - public static function writeClientFiles(bool $force=false) : void |
|
| 1033 | + public static function writeClientFiles(bool $force = false) : void |
|
| 1034 | 1034 | { |
| 1035 | 1035 | self::createGenerator()->writeFiles($force); |
| 1036 | 1036 | } |
@@ -1056,7 +1056,7 @@ discard block |
||
| 1056 | 1056 | |
| 1057 | 1057 | protected static function requireConfiguration() |
| 1058 | 1058 | { |
| 1059 | - if(!self::$configured) |
|
| 1059 | + if (!self::$configured) |
|
| 1060 | 1060 | { |
| 1061 | 1061 | throw new Localization_Exception( |
| 1062 | 1062 | 'The localization configuration is incomplete.', |
@@ -1065,7 +1065,7 @@ discard block |
||
| 1065 | 1065 | ); |
| 1066 | 1066 | } |
| 1067 | 1067 | |
| 1068 | - if(empty(self::$storageFile)) |
|
| 1068 | + if (empty(self::$storageFile)) |
|
| 1069 | 1069 | { |
| 1070 | 1070 | throw new Localization_Exception( |
| 1071 | 1071 | 'No localization storage file set', |
@@ -1074,7 +1074,7 @@ discard block |
||
| 1074 | 1074 | ); |
| 1075 | 1075 | } |
| 1076 | 1076 | |
| 1077 | - if(empty(self::$sources)) |
|
| 1077 | + if (empty(self::$sources)) |
|
| 1078 | 1078 | { |
| 1079 | 1079 | throw new Localization_Exception( |
| 1080 | 1080 | 'No source folders have been defined.', |
@@ -1106,7 +1106,7 @@ discard block |
||
| 1106 | 1106 | { |
| 1107 | 1107 | $ids = array(); |
| 1108 | 1108 | |
| 1109 | - foreach(self::$sources as $source) { |
|
| 1109 | + foreach (self::$sources as $source) { |
|
| 1110 | 1110 | $ids[] = $source->getID(); |
| 1111 | 1111 | } |
| 1112 | 1112 | |
@@ -1121,7 +1121,7 @@ discard block |
||
| 1121 | 1121 | { |
| 1122 | 1122 | $aliases = array(); |
| 1123 | 1123 | |
| 1124 | - foreach(self::$sources as $source) { |
|
| 1124 | + foreach (self::$sources as $source) { |
|
| 1125 | 1125 | $aliases[] = $source->getAlias(); |
| 1126 | 1126 | } |
| 1127 | 1127 | |
@@ -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, 1) . " is unknown in " . get_class($this), E_USER_NOTICE); |
|
| 87 | + trigger_error("symbol ".var_export($i, 1)." 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, 1) . " is unknown in " . get_class($this), E_USER_NOTICE); |
|
| 95 | + trigger_error("literal symbol ".var_export($i, 1)." 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"; |
@@ -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)) { |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | |
| 189 | 189 | $name = $locale->getName(); |
| 190 | 190 | |
| 191 | - if(isset($this->strings[$name])) { |
|
| 191 | + if (isset($this->strings[$name])) { |
|
| 192 | 192 | return $this->strings[$name]; |
| 193 | 193 | } |
| 194 | 194 | |
@@ -218,25 +218,25 @@ discard block |
||
| 218 | 218 | * @param boolean $editable |
| 219 | 219 | * @throws Localization_Exception |
| 220 | 220 | */ |
| 221 | - protected function renderStringsFile($type, Localization_Source $source, $hashes, $file, Localization_Locale $locale, $editable=true) |
|
| 221 | + protected function renderStringsFile($type, Localization_Source $source, $hashes, $file, Localization_Locale $locale, $editable = true) |
|
| 222 | 222 | { |
| 223 | 223 | $sourceID = $source->getID(); |
| 224 | 224 | |
| 225 | - $title = strtoupper($type).' TRANSLATION FILE FOR ' . strtoupper($locale->getLabel()); |
|
| 225 | + $title = strtoupper($type).' TRANSLATION FILE FOR '.strtoupper($locale->getLabel()); |
|
| 226 | 226 | |
| 227 | - $content = '; -------------------------------------------------------' . PHP_EOL; |
|
| 228 | - $content .= '; '. $title . PHP_EOL; |
|
| 229 | - $content .= '; -------------------------------------------------------' . PHP_EOL; |
|
| 230 | - $content .= '; ' . PHP_EOL; |
|
| 227 | + $content = '; -------------------------------------------------------'.PHP_EOL; |
|
| 228 | + $content .= '; '.$title.PHP_EOL; |
|
| 229 | + $content .= '; -------------------------------------------------------'.PHP_EOL; |
|
| 230 | + $content .= '; '.PHP_EOL; |
|
| 231 | 231 | |
| 232 | - if($editable) { |
|
| 233 | - $content .= '; You may edit text directly in this file under the following conditions:' . PHP_EOL; |
|
| 234 | - $content .= '; ' . PHP_EOL; |
|
| 235 | - $content .= '; 1) Do not to modify the keys (left hand side of the = sign)' . PHP_EOL; |
|
| 236 | - $content .= '; 2) Save the file as UTF-8 without BOM' . PHP_EOL; |
|
| 232 | + if ($editable) { |
|
| 233 | + $content .= '; You may edit text directly in this file under the following conditions:'.PHP_EOL; |
|
| 234 | + $content .= '; '.PHP_EOL; |
|
| 235 | + $content .= '; 1) Do not to modify the keys (left hand side of the = sign)'.PHP_EOL; |
|
| 236 | + $content .= '; 2) Save the file as UTF-8 without BOM'.PHP_EOL; |
|
| 237 | 237 | } else { |
| 238 | - $content .= '; Do NOT edit this file directly! It depends on the main translation file' . PHP_EOL; |
|
| 239 | - $content .= '; and any changes will be lost. Edit the main file instead.' . PHP_EOL; |
|
| 238 | + $content .= '; Do NOT edit this file directly! It depends on the main translation file'.PHP_EOL; |
|
| 239 | + $content .= '; and any changes will be lost. Edit the main file instead.'.PHP_EOL; |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | $content .= PHP_EOL; |
@@ -244,14 +244,14 @@ discard block |
||
| 244 | 244 | $saveList = array(); |
| 245 | 245 | foreach ($hashes as $hash) |
| 246 | 246 | { |
| 247 | - if(!$hash->hasSourceID($sourceID)) { |
|
| 247 | + if (!$hash->hasSourceID($sourceID)) { |
|
| 248 | 248 | continue; |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | $text = $this->getHashTranslation($hash->getHash(), $locale); |
| 252 | 252 | |
| 253 | 253 | // skip any empty strings |
| 254 | - if($text === null || trim($text) == '') { |
|
| 254 | + if ($text === null || trim($text) == '') { |
|
| 255 | 255 | continue; |
| 256 | 256 | } |
| 257 | 257 | |
@@ -263,11 +263,11 @@ discard block |
||
| 263 | 263 | |
| 264 | 264 | usort($saveList, array($this, 'callback_sortStrings')); |
| 265 | 265 | |
| 266 | - foreach($saveList as $entry) { |
|
| 267 | - $content .= $entry['hash'] . '= "' . $entry['text'] . '"' . PHP_EOL; |
|
| 266 | + foreach ($saveList as $entry) { |
|
| 267 | + $content .= $entry['hash'].'= "'.$entry['text'].'"'.PHP_EOL; |
|
| 268 | 268 | } |
| 269 | 269 | |
| 270 | - if(!file_put_contents($file, $content)) { |
|
| 270 | + if (!file_put_contents($file, $content)) { |
|
| 271 | 271 | throw new Localization_Exception( |
| 272 | 272 | 'Cannot save localization file', |
| 273 | 273 | sprintf( |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | public function callback_sortStrings($a, $b) |
| 294 | 294 | { |
| 295 | 295 | $result = strnatcasecmp($a['text'], $b['text']); |
| 296 | - if($result==0) { |
|
| 296 | + if ($result == 0) { |
|
| 297 | 297 | return strnatcmp($a['hash'], $b['hash']); |
| 298 | 298 | } |
| 299 | 299 | |
@@ -368,7 +368,7 @@ discard block |
||
| 368 | 368 | |
| 369 | 369 | // to avoid re-creating the hash for the same texts over and over, |
| 370 | 370 | // we keep track of the hashes we created, and re-use them. |
| 371 | - if(isset($this->reverseStrings[$text])) { |
|
| 371 | + if (isset($this->reverseStrings[$text])) { |
|
| 372 | 372 | $hash = $this->reverseStrings[$text]; |
| 373 | 373 | } else { |
| 374 | 374 | $hash = md5($text); |
@@ -429,15 +429,15 @@ discard block |
||
| 429 | 429 | * @param string $hash |
| 430 | 430 | * @return string|NULL |
| 431 | 431 | */ |
| 432 | - public function getHashTranslation($hash, Localization_Locale $locale=null) |
|
| 432 | + public function getHashTranslation($hash, Localization_Locale $locale = null) |
|
| 433 | 433 | { |
| 434 | - if(!$locale) { |
|
| 434 | + if (!$locale) { |
|
| 435 | 435 | $locale = $this->targetLocale; |
| 436 | 436 | } |
| 437 | 437 | |
| 438 | 438 | $localeName = $locale->getName(); |
| 439 | 439 | |
| 440 | - if(isset($this->strings[$localeName]) && isset($this->strings[$localeName][$hash])) { |
|
| 440 | + if (isset($this->strings[$localeName]) && isset($this->strings[$localeName][$hash])) { |
|
| 441 | 441 | return $this->strings[$localeName][$hash]; |
| 442 | 442 | } |
| 443 | 443 | |
@@ -454,10 +454,10 @@ discard block |
||
| 454 | 454 | { |
| 455 | 455 | $result = array(); |
| 456 | 456 | |
| 457 | - foreach($this->sources as $source) |
|
| 457 | + foreach ($this->sources as $source) |
|
| 458 | 458 | { |
| 459 | 459 | $localeFile = self::getClientStorageFile($locale, $source); |
| 460 | - if(!file_exists($localeFile)) { |
|
| 460 | + if (!file_exists($localeFile)) { |
|
| 461 | 461 | continue; |
| 462 | 462 | } |
| 463 | 463 | |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | { |
| 62 | 62 | $hash = $string->getHash(); |
| 63 | 63 | |
| 64 | - if(!isset($this->hashes[$hash])) { |
|
| 64 | + if (!isset($this->hashes[$hash])) { |
|
| 65 | 65 | $this->hashes[$hash] = new Localization_Scanner_StringHash($this, $hash); |
| 66 | 66 | } |
| 67 | 67 | |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | |
| 88 | 88 | public function getHash($hash) |
| 89 | 89 | { |
| 90 | - if(isset($this->hashes[$hash])) { |
|
| 90 | + if (isset($this->hashes[$hash])) { |
|
| 91 | 91 | return $this->hashes[$hash]; |
| 92 | 92 | } |
| 93 | 93 | |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | 'warnings' => array() |
| 107 | 107 | ); |
| 108 | 108 | |
| 109 | - foreach($this->hashes as $hash) |
|
| 109 | + foreach ($this->hashes as $hash) |
|
| 110 | 110 | { |
| 111 | 111 | $data['hashes'] = array_merge($data['hashes'], $hash->toArray()); |
| 112 | 112 | } |
@@ -118,11 +118,11 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | public function fromArray($array) : bool |
| 120 | 120 | { |
| 121 | - if(!isset($array['formatVersion']) || $array['formatVersion'] != self::STORAGE_FORMAT_VERSION) { |
|
| 121 | + if (!isset($array['formatVersion']) || $array['formatVersion'] != self::STORAGE_FORMAT_VERSION) { |
|
| 122 | 122 | return false; |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - foreach($array['hashes'] as $entry) |
|
| 125 | + foreach ($array['hashes'] as $entry) |
|
| 126 | 126 | { |
| 127 | 127 | $string = Localization_Scanner_StringInfo::fromArray($this, $entry); |
| 128 | 128 | $this->add($string); |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | { |
| 164 | 164 | $result = array(); |
| 165 | 165 | |
| 166 | - foreach($this->warnings as $def) { |
|
| 166 | + foreach ($this->warnings as $def) { |
|
| 167 | 167 | $result[] = new Localization_Scanner_StringsCollection_Warning($def); |
| 168 | 168 | } |
| 169 | 169 | |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | public function countFiles() : int |
| 179 | 179 | { |
| 180 | 180 | $amount = 0; |
| 181 | - foreach($this->hashes as $hash) { |
|
| 181 | + foreach ($this->hashes as $hash) { |
|
| 182 | 182 | $amount = $amount + $hash->countFiles(); |
| 183 | 183 | } |
| 184 | 184 | |
@@ -195,8 +195,8 @@ discard block |
||
| 195 | 195 | { |
| 196 | 196 | $hashes = array(); |
| 197 | 197 | |
| 198 | - foreach($this->hashes as $hash) { |
|
| 199 | - if($hash->hasSourceID($id)) { |
|
| 198 | + foreach ($this->hashes as $hash) { |
|
| 199 | + if ($hash->hasSourceID($id)) { |
|
| 200 | 200 | $hashes[] = $hash; |
| 201 | 201 | } |
| 202 | 202 | } |
@@ -214,8 +214,8 @@ discard block |
||
| 214 | 214 | { |
| 215 | 215 | $hashes = array(); |
| 216 | 216 | |
| 217 | - foreach($this->hashes as $hash) { |
|
| 218 | - if($hash->hasLanguageType($languageID)) { |
|
| 217 | + foreach ($this->hashes as $hash) { |
|
| 218 | + if ($hash->hasLanguageType($languageID)) { |
|
| 219 | 219 | $hashes[] = $hash; |
| 220 | 220 | } |
| 221 | 221 | } |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | |
| 75 | 75 | public function getProperty($name) |
| 76 | 76 | { |
| 77 | - if(isset($this->properties[$name])) { |
|
| 77 | + if (isset($this->properties[$name])) { |
|
| 78 | 78 | return $this->properties[$name]; |
| 79 | 79 | } |
| 80 | 80 | |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | $array['line'] |
| 124 | 124 | ); |
| 125 | 125 | |
| 126 | - foreach($array['properties'] as $name => $value) { |
|
| 126 | + foreach ($array['properties'] as $name => $value) { |
|
| 127 | 127 | $string->setProperty($name, $value); |
| 128 | 128 | } |
| 129 | 129 | |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | { |
| 49 | 49 | $entries = array(); |
| 50 | 50 | |
| 51 | - foreach($this->strings as $string) { |
|
| 51 | + foreach ($this->strings as $string) { |
|
| 52 | 52 | $entries[] = $string->toArray(); |
| 53 | 53 | } |
| 54 | 54 | |
@@ -68,8 +68,8 @@ discard block |
||
| 68 | 68 | { |
| 69 | 69 | $amount = 0; |
| 70 | 70 | |
| 71 | - foreach($this->strings as $string) { |
|
| 72 | - if($string->isFile()) { |
|
| 71 | + foreach ($this->strings as $string) { |
|
| 72 | + if ($string->isFile()) { |
|
| 73 | 73 | $amount++; |
| 74 | 74 | } |
| 75 | 75 | } |
@@ -84,8 +84,8 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | public function hasLanguageType(string $type) : bool |
| 86 | 86 | { |
| 87 | - foreach($this->strings as $string) { |
|
| 88 | - if($string->getLanguageType() == $type) { |
|
| 87 | + foreach ($this->strings as $string) { |
|
| 88 | + if ($string->getLanguageType() == $type) { |
|
| 89 | 89 | return true; |
| 90 | 90 | } |
| 91 | 91 | } |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | |
| 96 | 96 | public function getText() : string |
| 97 | 97 | { |
| 98 | - if(isset($this->strings[0])) { |
|
| 98 | + if (isset($this->strings[0])) { |
|
| 99 | 99 | return $this->strings[0]->getText(); |
| 100 | 100 | } |
| 101 | 101 | |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | $translator = Localization::getTranslator(); |
| 128 | 128 | $text = $translator->getHashTranslation($this->getHash()); |
| 129 | 129 | |
| 130 | - if($text !== null) { |
|
| 130 | + if ($text !== null) { |
|
| 131 | 131 | return $text; |
| 132 | 132 | } |
| 133 | 133 | |
@@ -142,14 +142,14 @@ discard block |
||
| 142 | 142 | { |
| 143 | 143 | $files = array(); |
| 144 | 144 | |
| 145 | - foreach($this->strings as $string) |
|
| 145 | + foreach ($this->strings as $string) |
|
| 146 | 146 | { |
| 147 | - if(!$string->isFile()) { |
|
| 147 | + if (!$string->isFile()) { |
|
| 148 | 148 | continue; |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | $file = $string->getSourceFile(); |
| 152 | - if(!in_array($file, $files)) { |
|
| 152 | + if (!in_array($file, $files)) { |
|
| 153 | 153 | $files[] = $file; |
| 154 | 154 | } |
| 155 | 155 | } |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | $files = $this->getFiles(); |
| 169 | 169 | $result = array(); |
| 170 | 170 | |
| 171 | - foreach($files as $path) { |
|
| 171 | + foreach ($files as $path) { |
|
| 172 | 172 | $result[] = basename($path); |
| 173 | 173 | } |
| 174 | 174 | |