@@ -40,7 +40,7 @@ |
||
| 40 | 40 | public function getFloat() |
| 41 | 41 | { |
| 42 | 42 | if ($this->decimals) { |
| 43 | - return ($this->number . '.' . $this->decimals) * 1; |
|
| 43 | + return ($this->number.'.'.$this->decimals) * 1; |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | return $this->number; |
@@ -6,22 +6,22 @@ discard block |
||
| 6 | 6 | |
| 7 | 7 | abstract class Localization_Source |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Human readable label for the source. |
|
| 11 | - * @var string |
|
| 12 | - */ |
|
| 9 | + /** |
|
| 10 | + * Human readable label for the source. |
|
| 11 | + * @var string |
|
| 12 | + */ |
|
| 13 | 13 | protected $label; |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Human readable group name to categorize the source. |
|
| 17 | - * @var string |
|
| 18 | - */ |
|
| 15 | + /** |
|
| 16 | + * Human readable group name to categorize the source. |
|
| 17 | + * @var string |
|
| 18 | + */ |
|
| 19 | 19 | protected $group; |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * The folder in which the localization files are stored |
|
| 23 | - * @var string |
|
| 24 | - */ |
|
| 21 | + /** |
|
| 22 | + * The folder in which the localization files are stored |
|
| 23 | + * @var string |
|
| 24 | + */ |
|
| 25 | 25 | protected $storageFolder; |
| 26 | 26 | |
| 27 | 27 | public function __construct(string $alias, string $label, string $group, string $storageFolder) |
@@ -54,16 +54,16 @@ discard block |
||
| 54 | 54 | return $this->storageFolder; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * Available during scanning. |
|
| 59 | - * @var Localization_Scanner_StringsCollection |
|
| 60 | - */ |
|
| 57 | + /** |
|
| 58 | + * Available during scanning. |
|
| 59 | + * @var Localization_Scanner_StringsCollection |
|
| 60 | + */ |
|
| 61 | 61 | protected $collection; |
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * Available during scanning. |
|
| 65 | - * @var Localization_Parser |
|
| 66 | - */ |
|
| 63 | + /** |
|
| 64 | + * Available during scanning. |
|
| 65 | + * @var Localization_Parser |
|
| 66 | + */ |
|
| 67 | 67 | protected $parser; |
| 68 | 68 | |
| 69 | 69 | public function scan(Localization_Scanner $scanner) |
@@ -94,13 +94,13 @@ discard block |
||
| 94 | 94 | */ |
| 95 | 95 | protected function parseFile($file) |
| 96 | 96 | { |
| 97 | - $this->log(sprintf('Parsing file [' . $file . '].')); |
|
| 97 | + $this->log(sprintf('Parsing file ['.$file.'].')); |
|
| 98 | 98 | |
| 99 | 99 | $language = $this->parser->parseFile($file); |
| 100 | 100 | |
| 101 | 101 | $texts = $language->getTexts(); |
| 102 | 102 | |
| 103 | - foreach($texts as $def) |
|
| 103 | + foreach ($texts as $def) |
|
| 104 | 104 | { |
| 105 | 105 | $this->collection->addFromFile( |
| 106 | 106 | $this->getID(), |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | $warnings = $language->getWarnings(); |
| 115 | 115 | |
| 116 | - foreach($warnings as $warning) { |
|
| 116 | + foreach ($warnings as $warning) { |
|
| 117 | 117 | $this->collection->addWarning($warning); |
| 118 | 118 | } |
| 119 | 119 | } |
@@ -140,9 +140,9 @@ discard block |
||
| 140 | 140 | $amount = 0; |
| 141 | 141 | |
| 142 | 142 | $hashes = $this->getHashes($scanner); |
| 143 | - foreach($hashes as $hash) { |
|
| 143 | + foreach ($hashes as $hash) { |
|
| 144 | 144 | $text = $translator->getHashTranslation($hash->getHash()); |
| 145 | - if(empty($text)) { |
|
| 145 | + if (empty($text)) { |
|
| 146 | 146 | $amount++; |
| 147 | 147 | } |
| 148 | 148 | } |
@@ -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(APP_ROOT . '/assets/classes/Localization/Currency/' . $currencyName . '.php'); |
|
| 95 | + return file_exists(APP_ROOT.'/assets/classes/Localization/Currency/'.$currencyName.'.php'); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | return $this->country->getNumberDecimalsSeparator(); |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | - public function makeReadable($number, $decimalPositions = 2, $addSymbol=true) |
|
| 268 | + public function makeReadable($number, $decimalPositions = 2, $addSymbol = true) |
|
| 269 | 269 | { |
| 270 | 270 | if ($number == null || $number == '') { |
| 271 | 271 | return null; |
@@ -284,14 +284,14 @@ discard block |
||
| 284 | 284 | |
| 285 | 285 | $number = $this->formatNumber($parsed->getFloat(), $decimalPositions); |
| 286 | 286 | |
| 287 | - if(!$addSymbol) { |
|
| 287 | + if (!$addSymbol) { |
|
| 288 | 288 | return $number; |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | if ($this->isSymbolOnFront()) { |
| 292 | - return $this->getSymbol() . ' ' . $number; |
|
| 292 | + return $this->getSymbol().' '.$number; |
|
| 293 | 293 | } |
| 294 | 294 | |
| 295 | - return $number . ' ' . $this->getSymbol(); |
|
| 295 | + return $number.' '.$this->getSymbol(); |
|
| 296 | 296 | } |
| 297 | 297 | } |
| 298 | 298 | \ No newline at end of file |
@@ -6,24 +6,24 @@ |
||
| 6 | 6 | |
| 7 | 7 | class Localization_Source_Folder extends Localization_Source |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * The folder under which all translateable files are kept. |
|
| 11 | - * @var string |
|
| 12 | - */ |
|
| 9 | + /** |
|
| 10 | + * The folder under which all translateable files are kept. |
|
| 11 | + * @var string |
|
| 12 | + */ |
|
| 13 | 13 | protected $sourcesFolder; |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * @var string |
|
| 17 | - */ |
|
| 15 | + /** |
|
| 16 | + * @var string |
|
| 17 | + */ |
|
| 18 | 18 | protected $id; |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * @param string $alias An alias for this source, to recognize it by. |
|
| 22 | - * @param string $label The human readable label, used in the editor. |
|
| 23 | - * @param string $group A human readable group label to group several sources by. Used in the editor. |
|
| 24 | - * @param string $storageFolder The folder in which to store the localization files. |
|
| 25 | - * @param string $sourcesFolder The folder in which to analyze files to find translateable strings. |
|
| 26 | - */ |
|
| 20 | + /** |
|
| 21 | + * @param string $alias An alias for this source, to recognize it by. |
|
| 22 | + * @param string $label The human readable label, used in the editor. |
|
| 23 | + * @param string $group A human readable group label to group several sources by. Used in the editor. |
|
| 24 | + * @param string $storageFolder The folder in which to store the localization files. |
|
| 25 | + * @param string $sourcesFolder The folder in which to analyze files to find translateable strings. |
|
| 26 | + */ |
|
| 27 | 27 | public function __construct(string $alias, string $label, string $group, string $storageFolder, string $sourcesFolder) |
| 28 | 28 | { |
| 29 | 29 | parent::__construct($alias, $label, $group, $storageFolder); |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | public function excludeFolder(string $folder) : Localization_Source_Folder |
| 51 | 51 | { |
| 52 | - if(!in_array($folder, $this->excludes['folders'])) { |
|
| 52 | + if (!in_array($folder, $this->excludes['folders'])) { |
|
| 53 | 53 | $this->excludes['folders'][] = $folder; |
| 54 | 54 | } |
| 55 | 55 | |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | public function excludeFolders(array $folders) : Localization_Source_Folder |
| 60 | 60 | { |
| 61 | - foreach($folders as $folder) { |
|
| 61 | + foreach ($folders as $folder) { |
|
| 62 | 62 | $this->excludeFolder($folder); |
| 63 | 63 | } |
| 64 | 64 | |
@@ -20,9 +20,9 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | abstract class Localization_Event |
| 22 | 22 | { |
| 23 | - /** |
|
| 24 | - * @var array |
|
| 25 | - */ |
|
| 23 | + /** |
|
| 24 | + * @var array |
|
| 25 | + */ |
|
| 26 | 26 | protected $args; |
| 27 | 27 | |
| 28 | 28 | public function __construct(array $args) |
@@ -30,13 +30,13 @@ discard block |
||
| 30 | 30 | $this->args = $args; |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * Fetches the argument at the specified index in the |
|
| 35 | - * event's arguments list, if it exists. |
|
| 36 | - * |
|
| 37 | - * @param int $index Zero-based index number. |
|
| 38 | - * @return mixed|NULL |
|
| 39 | - */ |
|
| 33 | + /** |
|
| 34 | + * Fetches the argument at the specified index in the |
|
| 35 | + * event's arguments list, if it exists. |
|
| 36 | + * |
|
| 37 | + * @param int $index Zero-based index number. |
|
| 38 | + * @return mixed|NULL |
|
| 39 | + */ |
|
| 40 | 40 | public function getArgument(int $index) |
| 41 | 41 | { |
| 42 | 42 | if(isset($this->args[$index])) { |
@@ -39,7 +39,7 @@ |
||
| 39 | 39 | */ |
| 40 | 40 | public function getArgument(int $index) |
| 41 | 41 | { |
| 42 | - if(isset($this->args[$index])) { |
|
| 42 | + if (isset($this->args[$index])) { |
|
| 43 | 43 | return $this->args[$index]; |
| 44 | 44 | } |
| 45 | 45 | |
@@ -18,24 +18,24 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | const FILES_CACHE_KEY = 'cachekey'; |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @var bool |
|
| 23 | - */ |
|
| 21 | + /** |
|
| 22 | + * @var bool |
|
| 23 | + */ |
|
| 24 | 24 | protected $force = false; |
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * @var Localization_Translator |
|
| 28 | - */ |
|
| 26 | + /** |
|
| 27 | + * @var Localization_Translator |
|
| 28 | + */ |
|
| 29 | 29 | protected $translator; |
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * @var string |
|
| 33 | - */ |
|
| 31 | + /** |
|
| 32 | + * @var string |
|
| 33 | + */ |
|
| 34 | 34 | protected $targetFolder; |
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * @var string |
|
| 38 | - */ |
|
| 36 | + /** |
|
| 37 | + * @var string |
|
| 38 | + */ |
|
| 39 | 39 | protected $cacheKeyFile; |
| 40 | 40 | |
| 41 | 41 | protected $cacheKey = ''; |
@@ -118,14 +118,14 @@ discard block |
||
| 118 | 118 | $this->writeCacheKey(); |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - /** |
|
| 122 | - * Retrieves a list of all localization client |
|
| 123 | - * files that are written to disk. This includes |
|
| 124 | - * the locale files and the libraries required |
|
| 125 | - * to make it work clientside. |
|
| 126 | - * |
|
| 127 | - * @return string[] |
|
| 128 | - */ |
|
| 121 | + /** |
|
| 122 | + * Retrieves a list of all localization client |
|
| 123 | + * files that are written to disk. This includes |
|
| 124 | + * the locale files and the libraries required |
|
| 125 | + * to make it work clientside. |
|
| 126 | + * |
|
| 127 | + * @return string[] |
|
| 128 | + */ |
|
| 129 | 129 | public function getFilesList() : array |
| 130 | 130 | { |
| 131 | 131 | $files = array(); |
@@ -273,11 +273,11 @@ discard block |
||
| 273 | 273 | $this->written[self::FILES_LOCALES] = true; |
| 274 | 274 | } |
| 275 | 275 | |
| 276 | - /** |
|
| 277 | - * Generates the cache key file, which is used to determine |
|
| 278 | - * automatically whether the client libraries need to be |
|
| 279 | - * refreshed. |
|
| 280 | - */ |
|
| 276 | + /** |
|
| 277 | + * Generates the cache key file, which is used to determine |
|
| 278 | + * automatically whether the client libraries need to be |
|
| 279 | + * refreshed. |
|
| 280 | + */ |
|
| 281 | 281 | protected function writeCacheKey() |
| 282 | 282 | { |
| 283 | 283 | if(file_exists($this->cacheKeyFile) && !$this->force) { |
@@ -289,18 +289,18 @@ discard block |
||
| 289 | 289 | $this->written[self::FILES_CACHE_KEY] = true; |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | - /** |
|
| 293 | - * Whether the specified files have been written to |
|
| 294 | - * disk this session. |
|
| 295 | - * |
|
| 296 | - * NOTE: only useful when called after <code>writeFiles</code>. |
|
| 297 | - * |
|
| 298 | - * @param string $filesID |
|
| 299 | - * |
|
| 300 | - * @see Localization_ClientGenerator::FILES_CACHE_KEY |
|
| 301 | - * @see Localization_ClientGenerator::FILES_LOCALES |
|
| 302 | - * @see Localization_ClientGenerator::FILES_LIBRARIES |
|
| 303 | - */ |
|
| 292 | + /** |
|
| 293 | + * Whether the specified files have been written to |
|
| 294 | + * disk this session. |
|
| 295 | + * |
|
| 296 | + * NOTE: only useful when called after <code>writeFiles</code>. |
|
| 297 | + * |
|
| 298 | + * @param string $filesID |
|
| 299 | + * |
|
| 300 | + * @see Localization_ClientGenerator::FILES_CACHE_KEY |
|
| 301 | + * @see Localization_ClientGenerator::FILES_LOCALES |
|
| 302 | + * @see Localization_ClientGenerator::FILES_LIBRARIES |
|
| 303 | + */ |
|
| 304 | 304 | public function areFilesWritten(string $filesID) |
| 305 | 305 | { |
| 306 | 306 | if(isset($this->written[$filesID])) { |
@@ -58,13 +58,13 @@ discard block |
||
| 58 | 58 | protected function initCache() |
| 59 | 59 | { |
| 60 | 60 | // ignore it if it does not exist. |
| 61 | - if(!file_exists($this->cacheKeyFile)) { |
|
| 61 | + if (!file_exists($this->cacheKeyFile)) { |
|
| 62 | 62 | return; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | $this->cacheKey = file_get_contents($this->cacheKeyFile); |
| 66 | 66 | |
| 67 | - if($this->cacheKey !== false) { |
|
| 67 | + if ($this->cacheKey !== false) { |
|
| 68 | 68 | return; |
| 69 | 69 | } |
| 70 | 70 | |
@@ -77,22 +77,22 @@ discard block |
||
| 77 | 77 | ); |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - public function writeFiles(bool $force=false) : void |
|
| 80 | + public function writeFiles(bool $force = false) : void |
|
| 81 | 81 | { |
| 82 | 82 | // reset the write states for all files |
| 83 | 83 | $fileIDs = array_keys($this->written); |
| 84 | - foreach($fileIDs as $fileID) { |
|
| 84 | + foreach ($fileIDs as $fileID) { |
|
| 85 | 85 | $this->written[$fileID] = false; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | // no client libraries folder set: ignore. |
| 89 | - if(empty($this->targetFolder)) { |
|
| 89 | + if (empty($this->targetFolder)) { |
|
| 90 | 90 | return; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | \AppUtils\FileHelper::createFolder($this->targetFolder); |
| 94 | 94 | |
| 95 | - if(!is_writable($this->targetFolder)) |
|
| 95 | + if (!is_writable($this->targetFolder)) |
|
| 96 | 96 | { |
| 97 | 97 | throw new Localization_Exception( |
| 98 | 98 | sprintf( |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | ); |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - if($this->cacheKey !== Localization::getClientLibrariesCacheKey()) { |
|
| 110 | + if ($this->cacheKey !== Localization::getClientLibrariesCacheKey()) { |
|
| 111 | 111 | $force = true; |
| 112 | 112 | } |
| 113 | 113 | |
@@ -130,16 +130,16 @@ discard block |
||
| 130 | 130 | { |
| 131 | 131 | $files = array(); |
| 132 | 132 | |
| 133 | - foreach($this->libraries as $fileName) |
|
| 133 | + foreach ($this->libraries as $fileName) |
|
| 134 | 134 | { |
| 135 | 135 | $files[] = $this->getLibraryFilePath($fileName); |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | $locales = Localization::getAppLocales(); |
| 139 | 139 | |
| 140 | - foreach($locales as $locale) |
|
| 140 | + foreach ($locales as $locale) |
|
| 141 | 141 | { |
| 142 | - if($locale->isNative()) { |
|
| 142 | + if ($locale->isNative()) { |
|
| 143 | 143 | continue; |
| 144 | 144 | } |
| 145 | 145 | |
@@ -153,9 +153,9 @@ discard block |
||
| 153 | 153 | { |
| 154 | 154 | $locales = Localization::getAppLocales(); |
| 155 | 155 | |
| 156 | - foreach($locales as $locale) |
|
| 156 | + foreach ($locales as $locale) |
|
| 157 | 157 | { |
| 158 | - if($locale->isNative()) { |
|
| 158 | + if ($locale->isNative()) { |
|
| 159 | 159 | continue; |
| 160 | 160 | } |
| 161 | 161 | |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | { |
| 173 | 173 | $sourceFolder = realpath(__DIR__.'/../js'); |
| 174 | 174 | |
| 175 | - if($sourceFolder === false) |
|
| 175 | + if ($sourceFolder === false) |
|
| 176 | 176 | { |
| 177 | 177 | throw new Localization_Exception( |
| 178 | 178 | 'Unexpected folder structure encountered.', |
@@ -184,11 +184,11 @@ discard block |
||
| 184 | 184 | ); |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - foreach($this->libraries as $fileName) |
|
| 187 | + foreach ($this->libraries as $fileName) |
|
| 188 | 188 | { |
| 189 | 189 | $targetFile = $this->getLibraryFilePath($fileName); |
| 190 | 190 | |
| 191 | - if(file_exists($targetFile) && !$this->force) { |
|
| 191 | + if (file_exists($targetFile) && !$this->force) { |
|
| 192 | 192 | continue; |
| 193 | 193 | } |
| 194 | 194 | |
@@ -235,16 +235,16 @@ discard block |
||
| 235 | 235 | { |
| 236 | 236 | $path = $this->getLocaleFilePath($locale); |
| 237 | 237 | |
| 238 | - if(file_exists($path) && !$this->force) { |
|
| 238 | + if (file_exists($path) && !$this->force) { |
|
| 239 | 239 | return; |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | $strings = $this->translator->getClientStrings($locale); |
| 243 | 243 | |
| 244 | 244 | $tokens = array(); |
| 245 | - foreach($strings as $hash => $text) |
|
| 245 | + foreach ($strings as $hash => $text) |
|
| 246 | 246 | { |
| 247 | - if(empty($text)) { |
|
| 247 | + if (empty($text)) { |
|
| 248 | 248 | continue; |
| 249 | 249 | } |
| 250 | 250 | |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | ); |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | - if(empty($tokens)) |
|
| 258 | + if (empty($tokens)) |
|
| 259 | 259 | { |
| 260 | 260 | $content = '/* No strings found. */'; |
| 261 | 261 | } |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | */ |
| 281 | 281 | protected function writeCacheKey() |
| 282 | 282 | { |
| 283 | - if(file_exists($this->cacheKeyFile) && !$this->force) { |
|
| 283 | + if (file_exists($this->cacheKeyFile) && !$this->force) { |
|
| 284 | 284 | return; |
| 285 | 285 | } |
| 286 | 286 | |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | */ |
| 304 | 304 | public function areFilesWritten(string $filesID) |
| 305 | 305 | { |
| 306 | - if(isset($this->written[$filesID])) { |
|
| 306 | + if (isset($this->written[$filesID])) { |
|
| 307 | 307 | return $this->written[$filesID]; |
| 308 | 308 | } |
| 309 | 309 | |
@@ -258,8 +258,7 @@ |
||
| 258 | 258 | if(empty($tokens)) |
| 259 | 259 | { |
| 260 | 260 | $content = '/* No strings found. */'; |
| 261 | - } |
|
| 262 | - else |
|
| 261 | + } else |
|
| 263 | 262 | { |
| 264 | 263 | $content = |
| 265 | 264 | '/**'.PHP_EOL. |
@@ -33,14 +33,14 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | protected $country; |
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * @var string |
|
| 38 | - */ |
|
| 36 | + /** |
|
| 37 | + * @var string |
|
| 38 | + */ |
|
| 39 | 39 | protected $countryCode; |
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * @var string |
|
| 43 | - */ |
|
| 41 | + /** |
|
| 42 | + * @var string |
|
| 43 | + */ |
|
| 44 | 44 | protected $languageCode; |
| 45 | 45 | |
| 46 | 46 | /** |
@@ -69,11 +69,11 @@ discard block |
||
| 69 | 69 | $this->languageCode = $tokens[0]; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * Retrieves the two-letter language code of the locale. |
|
| 74 | - * |
|
| 75 | - * @return string Language code, e.g. "en", "de" |
|
| 76 | - */ |
|
| 72 | + /** |
|
| 73 | + * Retrieves the two-letter language code of the locale. |
|
| 74 | + * |
|
| 75 | + * @return string Language code, e.g. "en", "de" |
|
| 76 | + */ |
|
| 77 | 77 | public function getLanguageCode() : string |
| 78 | 78 | { |
| 79 | 79 | return $this->languageCode; |
@@ -100,25 +100,25 @@ discard block |
||
| 100 | 100 | return $this->localeName; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - /** |
|
| 104 | - * Retrieves the shortened version of the locale name, |
|
| 105 | - * e.g. "en" or "de". |
|
| 106 | - * |
|
| 107 | - * @return string |
|
| 108 | - * @deprecated |
|
| 109 | - * @see Localization_Locale::getLanguageCode() |
|
| 110 | - */ |
|
| 103 | + /** |
|
| 104 | + * Retrieves the shortened version of the locale name, |
|
| 105 | + * e.g. "en" or "de". |
|
| 106 | + * |
|
| 107 | + * @return string |
|
| 108 | + * @deprecated |
|
| 109 | + * @see Localization_Locale::getLanguageCode() |
|
| 110 | + */ |
|
| 111 | 111 | public function getShortName() : string |
| 112 | 112 | { |
| 113 | 113 | return $this->getLanguageCode(); |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - /** |
|
| 117 | - * Retrieves the two-letter country code of |
|
| 118 | - * the locale. |
|
| 119 | - * |
|
| 120 | - * @return string Lowercase code, e.g. "uk" |
|
| 121 | - */ |
|
| 116 | + /** |
|
| 117 | + * Retrieves the two-letter country code of |
|
| 118 | + * the locale. |
|
| 119 | + * |
|
| 120 | + * @return string Lowercase code, e.g. "uk" |
|
| 121 | + */ |
|
| 122 | 122 | public function getCountryCode() : string |
| 123 | 123 | { |
| 124 | 124 | return $this->countryCode; |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | public function __construct(string $localeName) |
| 51 | 51 | { |
| 52 | - if(!self::isLocaleKnown($localeName)) |
|
| 52 | + if (!self::isLocaleKnown($localeName)) |
|
| 53 | 53 | { |
| 54 | 54 | throw new Localization_Exception( |
| 55 | 55 | 'Invalid locale', |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | */ |
| 145 | 145 | public function getLabel() : string |
| 146 | 146 | { |
| 147 | - switch($this->localeName) |
|
| 147 | + switch ($this->localeName) |
|
| 148 | 148 | { |
| 149 | 149 | case 'de_DE': |
| 150 | 150 | return t('German'); |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | throw new Localization_Exception( |
| 172 | - 'Label is missing for the locale ' . $this->localeName, |
|
| 172 | + 'Label is missing for the locale '.$this->localeName, |
|
| 173 | 173 | null, |
| 174 | 174 | self::ERROR_LOCALE_LABEL_MISSING |
| 175 | 175 | ); |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | */ |
| 182 | 182 | public function getCountry() : Localization_Country |
| 183 | 183 | { |
| 184 | - if(!isset($this->country)) { |
|
| 184 | + if (!isset($this->country)) { |
|
| 185 | 185 | $this->country = Localization::createCountry($this->countryCode); |
| 186 | 186 | } |
| 187 | 187 | |
@@ -17,49 +17,49 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | protected $parser; |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * The function names that are included in the search. |
|
| 22 | - * @var array |
|
| 23 | - */ |
|
| 20 | + /** |
|
| 21 | + * The function names that are included in the search. |
|
| 22 | + * @var array |
|
| 23 | + */ |
|
| 24 | 24 | protected $functionNames = array(); |
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * The tokens definitions. |
|
| 28 | - * @var array |
|
| 29 | - */ |
|
| 26 | + /** |
|
| 27 | + * The tokens definitions. |
|
| 28 | + * @var array |
|
| 29 | + */ |
|
| 30 | 30 | protected $tokens = array(); |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * The total amount of tokens found in the content. |
|
| 34 | - * @var integer |
|
| 35 | - */ |
|
| 32 | + /** |
|
| 33 | + * The total amount of tokens found in the content. |
|
| 34 | + * @var integer |
|
| 35 | + */ |
|
| 36 | 36 | protected $totalTokens = 0; |
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * All texts that have been collected. |
|
| 40 | - * @var array |
|
| 41 | - */ |
|
| 38 | + /** |
|
| 39 | + * All texts that have been collected. |
|
| 40 | + * @var array |
|
| 41 | + */ |
|
| 42 | 42 | protected $texts = array(); |
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * @var string |
|
| 46 | - */ |
|
| 44 | + /** |
|
| 45 | + * @var string |
|
| 46 | + */ |
|
| 47 | 47 | protected $content = ''; |
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * @var string |
|
| 51 | - */ |
|
| 49 | + /** |
|
| 50 | + * @var string |
|
| 51 | + */ |
|
| 52 | 52 | protected $id; |
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * @var array |
|
| 56 | - */ |
|
| 54 | + /** |
|
| 55 | + * @var array |
|
| 56 | + */ |
|
| 57 | 57 | protected $warnings = array(); |
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * The source file that was parsed (if any) |
|
| 61 | - * @var string |
|
| 62 | - */ |
|
| 59 | + /** |
|
| 60 | + * The source file that was parsed (if any) |
|
| 61 | + * @var string |
|
| 62 | + */ |
|
| 63 | 63 | protected $sourceFile = ''; |
| 64 | 64 | |
| 65 | 65 | public function __construct(Localization_Parser $parser) |
@@ -70,10 +70,10 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | abstract protected function getTokens() : array; |
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * Retrieves the ID of the language. |
|
| 75 | - * @return string E.g. "PHP", "Javascript" |
|
| 76 | - */ |
|
| 73 | + /** |
|
| 74 | + * Retrieves the ID of the language. |
|
| 75 | + * @return string E.g. "PHP", "Javascript" |
|
| 76 | + */ |
|
| 77 | 77 | public function getID() : string |
| 78 | 78 | { |
| 79 | 79 | if(!isset($this->id)) { |
@@ -93,12 +93,12 @@ discard block |
||
| 93 | 93 | return $this->sourceFile; |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - /** |
|
| 97 | - * Parses the code from a file. |
|
| 98 | - * |
|
| 99 | - * @param string $path |
|
| 100 | - * @throws Localization_Exception |
|
| 101 | - */ |
|
| 96 | + /** |
|
| 97 | + * Parses the code from a file. |
|
| 98 | + * |
|
| 99 | + * @param string $path |
|
| 100 | + * @throws Localization_Exception |
|
| 101 | + */ |
|
| 102 | 102 | public function parseFile(string $path) : void |
| 103 | 103 | { |
| 104 | 104 | if(!file_exists($path)) |
@@ -131,10 +131,10 @@ discard block |
||
| 131 | 131 | ); |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - /** |
|
| 135 | - * Parses a source code string. |
|
| 136 | - * @param string $content |
|
| 137 | - */ |
|
| 134 | + /** |
|
| 135 | + * Parses a source code string. |
|
| 136 | + * @param string $content |
|
| 137 | + */ |
|
| 138 | 138 | public function parseString($content) : void |
| 139 | 139 | { |
| 140 | 140 | $this->content = $content; |
@@ -175,11 +175,11 @@ discard block |
||
| 175 | 175 | ); |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - /** |
|
| 179 | - * Retrieves a list of all the function names that are |
|
| 180 | - * used as translation functions in the language. |
|
| 181 | - * @return array |
|
| 182 | - */ |
|
| 178 | + /** |
|
| 179 | + * Retrieves a list of all the function names that are |
|
| 180 | + * used as translation functions in the language. |
|
| 181 | + * @return array |
|
| 182 | + */ |
|
| 183 | 183 | public function getFunctionNames() : array |
| 184 | 184 | { |
| 185 | 185 | return $this->createToken('dummy')->getFunctionNames(); |
@@ -190,13 +190,13 @@ discard block |
||
| 190 | 190 | Localization::log(sprintf('%1$s parser | %2$s', $this->getID(), $message)); |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | - /** |
|
| 194 | - * Adds a warning message when a text cannot be parsed correctly for some reason. |
|
| 195 | - * |
|
| 196 | - * @param Localization_Parser_Token $token |
|
| 197 | - * @param string $message |
|
| 198 | - * @return Localization_Parser_Warning |
|
| 199 | - */ |
|
| 193 | + /** |
|
| 194 | + * Adds a warning message when a text cannot be parsed correctly for some reason. |
|
| 195 | + * |
|
| 196 | + * @param Localization_Parser_Token $token |
|
| 197 | + * @param string $message |
|
| 198 | + * @return Localization_Parser_Warning |
|
| 199 | + */ |
|
| 200 | 200 | protected function addWarning(Localization_Parser_Token $token, string $message) : Localization_Parser_Warning |
| 201 | 201 | { |
| 202 | 202 | $warning = new Localization_Parser_Warning($this, $token, $message); |
@@ -206,34 +206,34 @@ discard block |
||
| 206 | 206 | return $warning; |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | - /** |
|
| 210 | - * Whether any warnings were generated during parsing. |
|
| 211 | - * @return bool |
|
| 212 | - */ |
|
| 209 | + /** |
|
| 210 | + * Whether any warnings were generated during parsing. |
|
| 211 | + * @return bool |
|
| 212 | + */ |
|
| 213 | 213 | public function hasWarnings() : bool |
| 214 | 214 | { |
| 215 | 215 | return !empty($this->warnings); |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | - /** |
|
| 219 | - * Retrieves all warnings that were generated during parsing, |
|
| 220 | - * if any. |
|
| 221 | - * |
|
| 222 | - * @return Localization_Parser_Warning[] |
|
| 223 | - */ |
|
| 218 | + /** |
|
| 219 | + * Retrieves all warnings that were generated during parsing, |
|
| 220 | + * if any. |
|
| 221 | + * |
|
| 222 | + * @return Localization_Parser_Warning[] |
|
| 223 | + */ |
|
| 224 | 224 | public function getWarnings() |
| 225 | 225 | { |
| 226 | 226 | return $this->warnings; |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - /** |
|
| 230 | - * Creates a token instance: this retrieves information on |
|
| 231 | - * the language token being parsed. |
|
| 232 | - * |
|
| 233 | - * @param array|string $definition The token definition. |
|
| 234 | - * @param Localization_Parser_Token $parentToken |
|
| 235 | - * @return Localization_Parser_Token |
|
| 236 | - */ |
|
| 229 | + /** |
|
| 230 | + * Creates a token instance: this retrieves information on |
|
| 231 | + * the language token being parsed. |
|
| 232 | + * |
|
| 233 | + * @param array|string $definition The token definition. |
|
| 234 | + * @param Localization_Parser_Token $parentToken |
|
| 235 | + * @return Localization_Parser_Token |
|
| 236 | + */ |
|
| 237 | 237 | protected function createToken($definition, Localization_Parser_Token $parentToken=null) : Localization_Parser_Token |
| 238 | 238 | { |
| 239 | 239 | $class = '\AppLocalize\Localization_Parser_Token_'.$this->getID(); |
@@ -241,12 +241,12 @@ discard block |
||
| 241 | 241 | return new $class($definition, $parentToken); |
| 242 | 242 | } |
| 243 | 243 | |
| 244 | - /** |
|
| 245 | - * Parses a translation function token. |
|
| 246 | - * |
|
| 247 | - * @param int $number |
|
| 248 | - * @param Localization_Parser_Token $token |
|
| 249 | - */ |
|
| 244 | + /** |
|
| 245 | + * Parses a translation function token. |
|
| 246 | + * |
|
| 247 | + * @param int $number |
|
| 248 | + * @param Localization_Parser_Token $token |
|
| 249 | + */ |
|
| 250 | 250 | protected function parseToken(int $number, Localization_Parser_Token $token) |
| 251 | 251 | { |
| 252 | 252 | $textParts = array(); |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | */ |
| 77 | 77 | public function getID() : string |
| 78 | 78 | { |
| 79 | - if(!isset($this->id)) { |
|
| 79 | + if (!isset($this->id)) { |
|
| 80 | 80 | $this->id = str_replace('AppLocalize\Localization_Parser_Language_', '', get_class($this)); |
| 81 | 81 | } |
| 82 | 82 | |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | */ |
| 102 | 102 | public function parseFile(string $path) : void |
| 103 | 103 | { |
| 104 | - if(!file_exists($path)) |
|
| 104 | + if (!file_exists($path)) |
|
| 105 | 105 | { |
| 106 | 106 | throw new Localization_Exception( |
| 107 | 107 | sprintf('Source code file [%s] not found', basename($path)), |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | $this->sourceFile = $path; |
| 117 | 117 | $this->content = file_get_contents($path); |
| 118 | 118 | |
| 119 | - if($this->content !== false) { |
|
| 119 | + if ($this->content !== false) { |
|
| 120 | 120 | $this->parse(); |
| 121 | 121 | return; |
| 122 | 122 | } |
@@ -150,12 +150,12 @@ discard block |
||
| 150 | 150 | $this->tokens = $this->getTokens(); |
| 151 | 151 | $this->totalTokens = count($this->tokens); |
| 152 | 152 | |
| 153 | - for($i = 0; $i < $this->totalTokens; $i++) |
|
| 153 | + for ($i = 0; $i < $this->totalTokens; $i++) |
|
| 154 | 154 | { |
| 155 | 155 | $token = $this->createToken($this->tokens[$i]); |
| 156 | 156 | |
| 157 | - if($token->isTranslationFunction()) { |
|
| 158 | - $this->parseToken($i+1, $token); |
|
| 157 | + if ($token->isTranslationFunction()) { |
|
| 158 | + $this->parseToken($i + 1, $token); |
|
| 159 | 159 | } |
| 160 | 160 | } |
| 161 | 161 | } |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | return $this->texts; |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - protected function addResult($text, $line=null) |
|
| 168 | + protected function addResult($text, $line = null) |
|
| 169 | 169 | { |
| 170 | 170 | $this->log(sprintf('Line [%1$s] | Found string [%2$s]', $line, $text)); |
| 171 | 171 | |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | * @param Localization_Parser_Token $parentToken |
| 235 | 235 | * @return Localization_Parser_Token |
| 236 | 236 | */ |
| 237 | - protected function createToken($definition, Localization_Parser_Token $parentToken=null) : Localization_Parser_Token |
|
| 237 | + protected function createToken($definition, Localization_Parser_Token $parentToken = null) : Localization_Parser_Token |
|
| 238 | 238 | { |
| 239 | 239 | $class = '\AppLocalize\Localization_Parser_Token_'.$this->getID(); |
| 240 | 240 | |
@@ -253,43 +253,43 @@ discard block |
||
| 253 | 253 | $max = $number + 200; |
| 254 | 254 | $open = false; |
| 255 | 255 | |
| 256 | - for($i = $number; $i < $max; $i++) |
|
| 256 | + for ($i = $number; $i < $max; $i++) |
|
| 257 | 257 | { |
| 258 | - if(!isset($this->tokens[$i])) { |
|
| 258 | + if (!isset($this->tokens[$i])) { |
|
| 259 | 259 | break; |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | $subToken = $this->createToken($this->tokens[$i], $token); |
| 263 | 263 | |
| 264 | - if(!$open && $subToken->isOpeningFuncParams()) |
|
| 264 | + if (!$open && $subToken->isOpeningFuncParams()) |
|
| 265 | 265 | { |
| 266 | 266 | $open = true; |
| 267 | 267 | continue; |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | - if($open && $subToken->isClosingFuncParams()) { |
|
| 270 | + if ($open && $subToken->isClosingFuncParams()) { |
|
| 271 | 271 | break; |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | // additional parameters in the translation function, we don't want to capture these now. |
| 275 | - if($open && $subToken->isArgumentSeparator()) { |
|
| 275 | + if ($open && $subToken->isArgumentSeparator()) { |
|
| 276 | 276 | break; |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | - if($open && $subToken->isEncapsedString()) |
|
| 279 | + if ($open && $subToken->isEncapsedString()) |
|
| 280 | 280 | { |
| 281 | 281 | $textParts[] = $this->trimText($subToken->getValue()); |
| 282 | 282 | continue; |
| 283 | 283 | } |
| 284 | 284 | |
| 285 | - if($open && $subToken->isVariableOrFunction()) { |
|
| 285 | + if ($open && $subToken->isVariableOrFunction()) { |
|
| 286 | 286 | $textParts = null; |
| 287 | 287 | $this->addWarning($subToken, t('Variables or functions are not supported in translation functions.')); |
| 288 | 288 | break; |
| 289 | 289 | } |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | - if(empty($textParts)) { |
|
| 292 | + if (empty($textParts)) { |
|
| 293 | 293 | return; |
| 294 | 294 | } |
| 295 | 295 | |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | |
| 301 | 301 | protected function debug($text) |
| 302 | 302 | { |
| 303 | - if($this->debug) { |
|
| 303 | + if ($this->debug) { |
|
| 304 | 304 | echo $text; |
| 305 | 305 | } |
| 306 | 306 | } |
@@ -4,14 +4,14 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | abstract class Localization_Parser_Token |
| 6 | 6 | { |
| 7 | - /** |
|
| 8 | - * @var array|string |
|
| 9 | - */ |
|
| 7 | + /** |
|
| 8 | + * @var array|string |
|
| 9 | + */ |
|
| 10 | 10 | protected $definition; |
| 11 | 11 | |
| 12 | - /** |
|
| 13 | - * @var Localization_Parser_Token |
|
| 14 | - */ |
|
| 12 | + /** |
|
| 13 | + * @var Localization_Parser_Token |
|
| 14 | + */ |
|
| 15 | 15 | protected $parentToken; |
| 16 | 16 | |
| 17 | 17 | protected $token; |
@@ -66,6 +66,6 @@ discard block |
||
| 66 | 66 | 'value' => $this->getValue(), |
| 67 | 67 | 'line' => $this->getLine(), |
| 68 | 68 | 'isEncapsedString' => \AppUtils\ConvertHelper::bool2string($this->isEncapsedString()) |
| 69 | - ); |
|
| 69 | + ); |
|
| 70 | 70 | } |
| 71 | 71 | } |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | |
| 21 | 21 | protected $line = 0; |
| 22 | 22 | |
| 23 | - public function __construct($definition, Localization_Parser_Token $parentToken=null) |
|
| 23 | + public function __construct($definition, Localization_Parser_Token $parentToken = null) |
|
| 24 | 24 | { |
| 25 | 25 | $this->definition = $definition; |
| 26 | 26 | $this->parentToken = $parentToken; |