@@ -16,9 +16,9 @@ |
||
| 16 | 16 | die('<b>ERROR:</b> Autoloader not present. Run composer update first.'); |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * The composer autoloader |
|
| 21 | - */ |
|
| 19 | + /** |
|
| 20 | + * The composer autoloader |
|
| 21 | + */ |
|
| 22 | 22 | require_once $autoload; |
| 23 | 23 | |
| 24 | 24 | // the folder in which the localization .ini files are stored |
@@ -52,12 +52,12 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | const NAMESPACE_CONTENT = '__content'; |
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Collection of all locales by namespace (application, content, custom...). |
|
| 57 | - * |
|
| 58 | - * @var array |
|
| 59 | - * @see Localization::addLocale() |
|
| 60 | - */ |
|
| 55 | + /** |
|
| 56 | + * Collection of all locales by namespace (application, content, custom...). |
|
| 57 | + * |
|
| 58 | + * @var array |
|
| 59 | + * @see Localization::addLocale() |
|
| 60 | + */ |
|
| 61 | 61 | protected static $locales = array(); |
| 62 | 62 | |
| 63 | 63 | /** |
@@ -66,44 +66,44 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | private static $initDone = false; |
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * Path to the file in which the scanner results are stored. |
|
| 71 | - * @var string |
|
| 72 | - * @see Localization::configure() |
|
| 73 | - */ |
|
| 69 | + /** |
|
| 70 | + * Path to the file in which the scanner results are stored. |
|
| 71 | + * @var string |
|
| 72 | + * @see Localization::configure() |
|
| 73 | + */ |
|
| 74 | 74 | protected static $storageFile = ''; |
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * Path to the folder into which the client libraries are written. |
|
| 78 | - * @var string |
|
| 79 | - * @see Localization::setClientLibrariesFolder() |
|
| 80 | - */ |
|
| 76 | + /** |
|
| 77 | + * Path to the folder into which the client libraries are written. |
|
| 78 | + * @var string |
|
| 79 | + * @see Localization::setClientLibrariesFolder() |
|
| 80 | + */ |
|
| 81 | 81 | protected static $clientFolder = ''; |
| 82 | 82 | |
| 83 | - /** |
|
| 84 | - * If this key changes, client libraries are refreshed. |
|
| 85 | - * @var string |
|
| 86 | - * @see Localization::setClientLibrariesCacheKey() |
|
| 87 | - */ |
|
| 83 | + /** |
|
| 84 | + * If this key changes, client libraries are refreshed. |
|
| 85 | + * @var string |
|
| 86 | + * @see Localization::setClientLibrariesCacheKey() |
|
| 87 | + */ |
|
| 88 | 88 | protected static $clientCacheKey = ''; |
| 89 | 89 | |
| 90 | - /** |
|
| 91 | - * Whether the configuration has been made. |
|
| 92 | - * @var bool |
|
| 93 | - * @see Localization::configure() |
|
| 94 | - */ |
|
| 90 | + /** |
|
| 91 | + * Whether the configuration has been made. |
|
| 92 | + * @var bool |
|
| 93 | + * @see Localization::configure() |
|
| 94 | + */ |
|
| 95 | 95 | protected static $configured = false; |
| 96 | 96 | |
| 97 | - /** |
|
| 98 | - * Stores event listener instances. |
|
| 99 | - * @var array |
|
| 100 | - */ |
|
| 97 | + /** |
|
| 98 | + * Stores event listener instances. |
|
| 99 | + * @var array |
|
| 100 | + */ |
|
| 101 | 101 | protected static $listeners = array(); |
| 102 | 102 | |
| 103 | - /** |
|
| 104 | - * @var integer |
|
| 105 | - * @see Localization::addEventListener() |
|
| 106 | - */ |
|
| 103 | + /** |
|
| 104 | + * @var integer |
|
| 105 | + * @see Localization::addEventListener() |
|
| 106 | + */ |
|
| 107 | 107 | protected static $listenersCounter = 0; |
| 108 | 108 | |
| 109 | 109 | /** |
@@ -150,12 +150,12 @@ discard block |
||
| 150 | 150 | return self::getLocalesByNS(self::NAMESPACE_APPLICATION); |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - /** |
|
| 154 | - * Retrieves all locales in the specified namespace. |
|
| 155 | - * |
|
| 156 | - * @param string $namespace |
|
| 157 | - * @return Localization_Locale[] |
|
| 158 | - */ |
|
| 153 | + /** |
|
| 154 | + * Retrieves all locales in the specified namespace. |
|
| 155 | + * |
|
| 156 | + * @param string $namespace |
|
| 157 | + * @return Localization_Locale[] |
|
| 158 | + */ |
|
| 159 | 159 | public static function getLocalesByNS(string $namespace) |
| 160 | 160 | { |
| 161 | 161 | if(isset(self::$locales[$namespace])) { |
@@ -172,35 +172,35 @@ discard block |
||
| 172 | 172 | ); |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - /** |
|
| 176 | - * Adds an application locale to use in the application. |
|
| 177 | - * |
|
| 178 | - * @param string $localeName |
|
| 179 | - * @return Localization_Locale |
|
| 180 | - */ |
|
| 175 | + /** |
|
| 176 | + * Adds an application locale to use in the application. |
|
| 177 | + * |
|
| 178 | + * @param string $localeName |
|
| 179 | + * @return Localization_Locale |
|
| 180 | + */ |
|
| 181 | 181 | public static function addAppLocale(string $localeName) : Localization_Locale |
| 182 | 182 | { |
| 183 | 183 | return self::addLocaleByNS($localeName, self::NAMESPACE_APPLICATION); |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - /** |
|
| 187 | - * Adds a content locale to use for content in the application. |
|
| 188 | - * |
|
| 189 | - * @param string $localeName |
|
| 190 | - * @return Localization_Locale |
|
| 191 | - */ |
|
| 186 | + /** |
|
| 187 | + * Adds a content locale to use for content in the application. |
|
| 188 | + * |
|
| 189 | + * @param string $localeName |
|
| 190 | + * @return Localization_Locale |
|
| 191 | + */ |
|
| 192 | 192 | public static function addContentLocale(string $localeName) : Localization_Locale |
| 193 | 193 | { |
| 194 | 194 | return self::addLocaleByNS($localeName, self::NAMESPACE_CONTENT); |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - /** |
|
| 198 | - * Adds a locale to the specified namespace. |
|
| 199 | - * |
|
| 200 | - * @param string $localeName |
|
| 201 | - * @param string $namespace |
|
| 202 | - * @return Localization_Locale |
|
| 203 | - */ |
|
| 197 | + /** |
|
| 198 | + * Adds a locale to the specified namespace. |
|
| 199 | + * |
|
| 200 | + * @param string $localeName |
|
| 201 | + * @param string $namespace |
|
| 202 | + * @return Localization_Locale |
|
| 203 | + */ |
|
| 204 | 204 | public static function addLocaleByNS(string $localeName, string $namespace) : Localization_Locale |
| 205 | 205 | { |
| 206 | 206 | if(!isset(self::$locales[$namespace])) { |
@@ -242,11 +242,11 @@ discard block |
||
| 242 | 242 | return new $className(); |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | - /** |
|
| 246 | - * Retrieves the currency of the selected app locale. |
|
| 247 | - * |
|
| 248 | - * @return Localization_Currency |
|
| 249 | - */ |
|
| 245 | + /** |
|
| 246 | + * Retrieves the currency of the selected app locale. |
|
| 247 | + * |
|
| 248 | + * @return Localization_Currency |
|
| 249 | + */ |
|
| 250 | 250 | public static function getAppCurrency() : Localization_Currency |
| 251 | 251 | { |
| 252 | 252 | return self::getCurrencyNS(self::NAMESPACE_APPLICATION); |
@@ -283,44 +283,44 @@ discard block |
||
| 283 | 283 | return self::getSelectedLocaleByNS(self::NAMESPACE_APPLICATION); |
| 284 | 284 | } |
| 285 | 285 | |
| 286 | - /** |
|
| 287 | - * Retrieves the name of the selected application locale. |
|
| 288 | - * |
|
| 289 | - * @return string |
|
| 290 | - */ |
|
| 286 | + /** |
|
| 287 | + * Retrieves the name of the selected application locale. |
|
| 288 | + * |
|
| 289 | + * @return string |
|
| 290 | + */ |
|
| 291 | 291 | public static function getAppLocaleName() : string |
| 292 | 292 | { |
| 293 | 293 | return self::getLocaleNameByNS(self::NAMESPACE_APPLICATION); |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | - /** |
|
| 297 | - * Retrieves the names of the available application locales. |
|
| 298 | - * @return string[] |
|
| 299 | - */ |
|
| 296 | + /** |
|
| 297 | + * Retrieves the names of the available application locales. |
|
| 298 | + * @return string[] |
|
| 299 | + */ |
|
| 300 | 300 | public static function getAppLocaleNames() : array |
| 301 | 301 | { |
| 302 | 302 | return self::getLocaleNamesByNS(self::NAMESPACE_APPLICATION); |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | - /** |
|
| 306 | - * Retrieves the selected locale name in the specified namespace. |
|
| 307 | - * |
|
| 308 | - * @param string $namespace |
|
| 309 | - * @throws Localization_Exception |
|
| 310 | - * @return string |
|
| 311 | - */ |
|
| 305 | + /** |
|
| 306 | + * Retrieves the selected locale name in the specified namespace. |
|
| 307 | + * |
|
| 308 | + * @param string $namespace |
|
| 309 | + * @throws Localization_Exception |
|
| 310 | + * @return string |
|
| 311 | + */ |
|
| 312 | 312 | public static function getLocaleNameByNS(string $namespace) : string |
| 313 | 313 | { |
| 314 | 314 | return self::getSelectedKeyByNS('name', $namespace); |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | - /** |
|
| 318 | - * Retrieves the selected locale instance for the specified namespace. |
|
| 319 | - * |
|
| 320 | - * @param string $namespace |
|
| 321 | - * @return Localization_Locale |
|
| 322 | - * @throws Localization_Exception |
|
| 323 | - */ |
|
| 317 | + /** |
|
| 318 | + * Retrieves the selected locale instance for the specified namespace. |
|
| 319 | + * |
|
| 320 | + * @param string $namespace |
|
| 321 | + * @return Localization_Locale |
|
| 322 | + * @throws Localization_Exception |
|
| 323 | + */ |
|
| 324 | 324 | public static function getSelectedLocaleByNS(string $namespace) : Localization_Locale |
| 325 | 325 | { |
| 326 | 326 | return self::getSelectedKeyByNS('locale', $namespace); |
@@ -345,20 +345,20 @@ discard block |
||
| 345 | 345 | ); |
| 346 | 346 | } |
| 347 | 347 | |
| 348 | - /** |
|
| 349 | - * Stores the selected locale names by namespace. |
|
| 350 | - * @var string[] |
|
| 351 | - */ |
|
| 348 | + /** |
|
| 349 | + * Stores the selected locale names by namespace. |
|
| 350 | + * @var string[] |
|
| 351 | + */ |
|
| 352 | 352 | protected static $selected = array(); |
| 353 | 353 | |
| 354 | - /** |
|
| 355 | - * Selects the active locale for the specified namespace. |
|
| 356 | - * |
|
| 357 | - * @param string $localeName |
|
| 358 | - * @param string $namespace |
|
| 359 | - * @return Localization_Locale |
|
| 360 | - * @throws Localization_Exception |
|
| 361 | - */ |
|
| 354 | + /** |
|
| 355 | + * Selects the active locale for the specified namespace. |
|
| 356 | + * |
|
| 357 | + * @param string $localeName |
|
| 358 | + * @param string $namespace |
|
| 359 | + * @return Localization_Locale |
|
| 360 | + * @throws Localization_Exception |
|
| 361 | + */ |
|
| 362 | 362 | public static function selectLocaleByNS(string $localeName, string $namespace) : Localization_Locale |
| 363 | 363 | { |
| 364 | 364 | self::requireNamespace($namespace); |
@@ -394,13 +394,13 @@ discard block |
||
| 394 | 394 | return $locale; |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | - /** |
|
| 398 | - * Triggers the specified event, with the provided arguments. |
|
| 399 | - * |
|
| 400 | - * @param string $name The event name. |
|
| 401 | - * @param array $argsList |
|
| 402 | - * @see Localization_Event |
|
| 403 | - */ |
|
| 397 | + /** |
|
| 398 | + * Triggers the specified event, with the provided arguments. |
|
| 399 | + * |
|
| 400 | + * @param string $name The event name. |
|
| 401 | + * @param array $argsList |
|
| 402 | + * @see Localization_Event |
|
| 403 | + */ |
|
| 404 | 404 | protected static function triggerEvent(string $name, array $argsList) : Localization_Event |
| 405 | 405 | { |
| 406 | 406 | $class = '\AppLocalize\Localization_Event_'.$name; |
@@ -421,14 +421,14 @@ discard block |
||
| 421 | 421 | return $event; |
| 422 | 422 | } |
| 423 | 423 | |
| 424 | - /** |
|
| 425 | - * Adds a listener to the specified event name. |
|
| 426 | - * |
|
| 427 | - * @param string $eventName |
|
| 428 | - * @param callable $callback |
|
| 429 | - * @param array $args Additional arguments to add to the event |
|
| 430 | - * @return int The listener number. |
|
| 431 | - */ |
|
| 424 | + /** |
|
| 425 | + * Adds a listener to the specified event name. |
|
| 426 | + * |
|
| 427 | + * @param string $eventName |
|
| 428 | + * @param callable $callback |
|
| 429 | + * @param array $args Additional arguments to add to the event |
|
| 430 | + * @return int The listener number. |
|
| 431 | + */ |
|
| 432 | 432 | public static function addEventListener(string $eventName, $callback, array $args=array()) : int |
| 433 | 433 | { |
| 434 | 434 | if(!isset(self::$listeners[$eventName])) { |
@@ -458,43 +458,43 @@ discard block |
||
| 458 | 458 | return self::$listenersCounter; |
| 459 | 459 | } |
| 460 | 460 | |
| 461 | - /** |
|
| 462 | - * Adds an event listener for the <code>LocaleChanged</code> event, |
|
| 463 | - * which is triggered every time a locale is changed in any of the |
|
| 464 | - * available namespaces. |
|
| 465 | - * |
|
| 466 | - * The first parameter of the callback is always the event instance. |
|
| 467 | - * |
|
| 468 | - * @param callable $callback The listener function to call. |
|
| 469 | - * @param array $args Optional indexed array with additional arguments to pass on to the callback function. |
|
| 470 | - * @return int |
|
| 471 | - * @see Localization_Event_LocaleChanged |
|
| 472 | - */ |
|
| 461 | + /** |
|
| 462 | + * Adds an event listener for the <code>LocaleChanged</code> event, |
|
| 463 | + * which is triggered every time a locale is changed in any of the |
|
| 464 | + * available namespaces. |
|
| 465 | + * |
|
| 466 | + * The first parameter of the callback is always the event instance. |
|
| 467 | + * |
|
| 468 | + * @param callable $callback The listener function to call. |
|
| 469 | + * @param array $args Optional indexed array with additional arguments to pass on to the callback function. |
|
| 470 | + * @return int |
|
| 471 | + * @see Localization_Event_LocaleChanged |
|
| 472 | + */ |
|
| 473 | 473 | public static function onLocaleChanged($callback, array $args=array()) : int |
| 474 | 474 | { |
| 475 | 475 | return self::addEventListener('LocaleChanged', $callback, $args); |
| 476 | 476 | } |
| 477 | 477 | |
| 478 | - /** |
|
| 479 | - * Selects the application locale to use. |
|
| 480 | - * |
|
| 481 | - * @param string $localeName |
|
| 482 | - * @return Localization_Locale |
|
| 483 | - */ |
|
| 478 | + /** |
|
| 479 | + * Selects the application locale to use. |
|
| 480 | + * |
|
| 481 | + * @param string $localeName |
|
| 482 | + * @return Localization_Locale |
|
| 483 | + */ |
|
| 484 | 484 | public static function selectAppLocale(string $localeName) : Localization_Locale |
| 485 | 485 | { |
| 486 | 486 | return self::selectLocaleByNS($localeName, self::NAMESPACE_APPLICATION); |
| 487 | 487 | } |
| 488 | 488 | |
| 489 | - /** |
|
| 490 | - * Retrieves an application locale by its name. |
|
| 491 | - * Note that the locale must have been added first. |
|
| 492 | - * |
|
| 493 | - * @param string $localeName |
|
| 494 | - * @throws Localization_Exception |
|
| 495 | - * @return Localization_Locale |
|
| 496 | - * @see Localization::appLocaleExists() |
|
| 497 | - */ |
|
| 489 | + /** |
|
| 490 | + * Retrieves an application locale by its name. |
|
| 491 | + * Note that the locale must have been added first. |
|
| 492 | + * |
|
| 493 | + * @param string $localeName |
|
| 494 | + * @throws Localization_Exception |
|
| 495 | + * @return Localization_Locale |
|
| 496 | + * @see Localization::appLocaleExists() |
|
| 497 | + */ |
|
| 498 | 498 | public static function getAppLocaleByName(string $localeName) : Localization_Locale |
| 499 | 499 | { |
| 500 | 500 | return self::getLocaleByNameNS($localeName, self::NAMESPACE_APPLICATION); |
@@ -528,22 +528,22 @@ discard block |
||
| 528 | 528 | return self::getLocalesByNS(self::NAMESPACE_CONTENT); |
| 529 | 529 | } |
| 530 | 530 | |
| 531 | - /** |
|
| 532 | - * Retrieves the names of all content locales that have been added. |
|
| 533 | - * @return string[] |
|
| 534 | - */ |
|
| 531 | + /** |
|
| 532 | + * Retrieves the names of all content locales that have been added. |
|
| 533 | + * @return string[] |
|
| 534 | + */ |
|
| 535 | 535 | public static function getContentLocaleNames() |
| 536 | 536 | { |
| 537 | 537 | return self::getLocaleNamesByNS(self::NAMESPACE_CONTENT); |
| 538 | 538 | } |
| 539 | 539 | |
| 540 | - /** |
|
| 541 | - * Retrieves all locale names available in the specified namespace. |
|
| 542 | - * The names are sorted alphabetically. |
|
| 543 | - * |
|
| 544 | - * @param string $namespace |
|
| 545 | - * @return array|array |
|
| 546 | - */ |
|
| 540 | + /** |
|
| 541 | + * Retrieves all locale names available in the specified namespace. |
|
| 542 | + * The names are sorted alphabetically. |
|
| 543 | + * |
|
| 544 | + * @param string $namespace |
|
| 545 | + * @return array|array |
|
| 546 | + */ |
|
| 547 | 547 | public static function getLocaleNamesByNS(string $namespace) |
| 548 | 548 | { |
| 549 | 549 | self::requireNamespace($namespace); |
@@ -553,7 +553,7 @@ discard block |
||
| 553 | 553 | sort($names); |
| 554 | 554 | |
| 555 | 555 | return $names; |
| 556 | - } |
|
| 556 | + } |
|
| 557 | 557 | |
| 558 | 558 | /** |
| 559 | 559 | * Checks by the locale name if the specified locale is |
@@ -582,14 +582,14 @@ discard block |
||
| 582 | 582 | return self::getLocaleByNameNS($localeName, self::NAMESPACE_CONTENT); |
| 583 | 583 | } |
| 584 | 584 | |
| 585 | - /** |
|
| 586 | - * Retrieves a locale by its name in the specified namespace. |
|
| 587 | - * |
|
| 588 | - * @param string $localeName |
|
| 589 | - * @param string $namespace |
|
| 590 | - * @throws Localization_Exception |
|
| 591 | - * @return Localization_Locale |
|
| 592 | - */ |
|
| 585 | + /** |
|
| 586 | + * Retrieves a locale by its name in the specified namespace. |
|
| 587 | + * |
|
| 588 | + * @param string $localeName |
|
| 589 | + * @param string $namespace |
|
| 590 | + * @throws Localization_Exception |
|
| 591 | + * @return Localization_Locale |
|
| 592 | + */ |
|
| 593 | 593 | public static function getLocaleByNameNS(string $localeName, string $namespace) : Localization_Locale |
| 594 | 594 | { |
| 595 | 595 | self::requireNamespace($namespace); |
@@ -649,10 +649,10 @@ discard block |
||
| 649 | 649 | return self::selectLocaleByNS($localeName, self::NAMESPACE_CONTENT); |
| 650 | 650 | } |
| 651 | 651 | |
| 652 | - /** |
|
| 653 | - * Checks whether the localization has been configured entirely. |
|
| 654 | - * @return bool |
|
| 655 | - */ |
|
| 652 | + /** |
|
| 653 | + * Checks whether the localization has been configured entirely. |
|
| 654 | + * @return bool |
|
| 655 | + */ |
|
| 656 | 656 | public static function isConfigured() : bool |
| 657 | 657 | { |
| 658 | 658 | return self::$configured; |
@@ -719,29 +719,29 @@ discard block |
||
| 719 | 719 | ); |
| 720 | 720 | } |
| 721 | 721 | |
| 722 | - /** |
|
| 723 | - * Injects a content locales selector element into the specified |
|
| 724 | - * HTML QuickForm2 container. |
|
| 725 | - * |
|
| 726 | - * @param string $elementName |
|
| 727 | - * @param \HTML_QuickForm2_Container $container |
|
| 728 | - * @param string $label |
|
| 729 | - * @return \HTML_QuickForm2_Element_Select |
|
| 730 | - */ |
|
| 722 | + /** |
|
| 723 | + * Injects a content locales selector element into the specified |
|
| 724 | + * HTML QuickForm2 container. |
|
| 725 | + * |
|
| 726 | + * @param string $elementName |
|
| 727 | + * @param \HTML_QuickForm2_Container $container |
|
| 728 | + * @param string $label |
|
| 729 | + * @return \HTML_QuickForm2_Element_Select |
|
| 730 | + */ |
|
| 731 | 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 | } |
| 735 | 735 | |
| 736 | - /** |
|
| 737 | - * Injects an app locales selector element into the specified |
|
| 736 | + /** |
|
| 737 | + * Injects an app locales selector element into the specified |
|
| 738 | 738 | * HTML QuickForm2 container. |
| 739 | 739 | * |
| 740 | - * @param string $elementName |
|
| 741 | - * @param \HTML_QuickForm2_Container $container |
|
| 742 | - * @param string|NULL $label |
|
| 743 | - * @return \HTML_QuickForm2_Element_Select |
|
| 744 | - */ |
|
| 740 | + * @param string $elementName |
|
| 741 | + * @param \HTML_QuickForm2_Container $container |
|
| 742 | + * @param string|NULL $label |
|
| 743 | + * @return \HTML_QuickForm2_Element_Select |
|
| 744 | + */ |
|
| 745 | 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); |
@@ -776,26 +776,26 @@ discard block |
||
| 776 | 776 | return $select; |
| 777 | 777 | } |
| 778 | 778 | |
| 779 | - /** |
|
| 780 | - * @var Localization_Source[] |
|
| 781 | - */ |
|
| 779 | + /** |
|
| 780 | + * @var Localization_Source[] |
|
| 781 | + */ |
|
| 782 | 782 | protected static $sources = array(); |
| 783 | 783 | |
| 784 | - /** |
|
| 785 | - * @var string[] |
|
| 786 | - */ |
|
| 784 | + /** |
|
| 785 | + * @var string[] |
|
| 786 | + */ |
|
| 787 | 787 | protected static $excludeFolders = array(); |
| 788 | 788 | |
| 789 | - /** |
|
| 790 | - * @var string[] |
|
| 791 | - */ |
|
| 789 | + /** |
|
| 790 | + * @var string[] |
|
| 791 | + */ |
|
| 792 | 792 | protected static $excludeFiles = array(); |
| 793 | 793 | |
| 794 | - /** |
|
| 795 | - * Retrieves all currently available sources. |
|
| 796 | - * |
|
| 797 | - * @return \AppLocalize\Localization_Source[] |
|
| 798 | - */ |
|
| 794 | + /** |
|
| 795 | + * Retrieves all currently available sources. |
|
| 796 | + * |
|
| 797 | + * @return \AppLocalize\Localization_Source[] |
|
| 798 | + */ |
|
| 799 | 799 | public static function getSources() |
| 800 | 800 | { |
| 801 | 801 | return self::$sources; |
@@ -827,10 +827,10 @@ discard block |
||
| 827 | 827 | return $source; |
| 828 | 828 | } |
| 829 | 829 | |
| 830 | - /** |
|
| 831 | - * Retrieves all sources grouped by their group name. |
|
| 832 | - * @return Localization_Source[] |
|
| 833 | - */ |
|
| 830 | + /** |
|
| 831 | + * Retrieves all sources grouped by their group name. |
|
| 832 | + * @return Localization_Source[] |
|
| 833 | + */ |
|
| 834 | 834 | public static function getSourcesGrouped() |
| 835 | 835 | { |
| 836 | 836 | $sources = self::getSources(); |
@@ -851,11 +851,11 @@ discard block |
||
| 851 | 851 | return $grouped; |
| 852 | 852 | } |
| 853 | 853 | |
| 854 | - /** |
|
| 855 | - * Checks whether a specific source exists by its ID. |
|
| 856 | - * @param string $sourceID |
|
| 857 | - * @return boolean |
|
| 858 | - */ |
|
| 854 | + /** |
|
| 855 | + * Checks whether a specific source exists by its ID. |
|
| 856 | + * @param string $sourceID |
|
| 857 | + * @return boolean |
|
| 858 | + */ |
|
| 859 | 859 | public static function sourceExists(string $sourceID) : bool |
| 860 | 860 | { |
| 861 | 861 | $sources = self::getSources(); |
@@ -868,11 +868,11 @@ discard block |
||
| 868 | 868 | return false; |
| 869 | 869 | } |
| 870 | 870 | |
| 871 | - /** |
|
| 872 | - * Checks whether a specific source exists by its alias. |
|
| 873 | - * @param string $sourceAlias |
|
| 874 | - * @return boolean |
|
| 875 | - */ |
|
| 871 | + /** |
|
| 872 | + * Checks whether a specific source exists by its alias. |
|
| 873 | + * @param string $sourceAlias |
|
| 874 | + * @return boolean |
|
| 875 | + */ |
|
| 876 | 876 | public static function sourceAliasExists(string $sourceAlias) : bool |
| 877 | 877 | { |
| 878 | 878 | $sources = self::getSources(); |
@@ -885,13 +885,13 @@ discard block |
||
| 885 | 885 | return false; |
| 886 | 886 | } |
| 887 | 887 | |
| 888 | - /** |
|
| 889 | - * Retrieves a localization source by its ID. |
|
| 890 | - * |
|
| 891 | - * @param string $sourceID |
|
| 892 | - * @throws Localization_Exception |
|
| 893 | - * @return Localization_Source |
|
| 894 | - */ |
|
| 888 | + /** |
|
| 889 | + * Retrieves a localization source by its ID. |
|
| 890 | + * |
|
| 891 | + * @param string $sourceID |
|
| 892 | + * @throws Localization_Exception |
|
| 893 | + * @return Localization_Source |
|
| 894 | + */ |
|
| 895 | 895 | public static function getSourceByID(string $sourceID) : Localization_Source |
| 896 | 896 | { |
| 897 | 897 | $sources = self::getSources(); |
@@ -937,13 +937,13 @@ discard block |
||
| 937 | 937 | ); |
| 938 | 938 | } |
| 939 | 939 | |
| 940 | - /** |
|
| 941 | - * Creates the scanner instance that is used to find |
|
| 942 | - * all translateable strings in the application. |
|
| 943 | - * |
|
| 944 | - * @param string $storageFile Path to the file in which to store string information. |
|
| 945 | - * @return Localization_Scanner |
|
| 946 | - */ |
|
| 940 | + /** |
|
| 941 | + * Creates the scanner instance that is used to find |
|
| 942 | + * all translateable strings in the application. |
|
| 943 | + * |
|
| 944 | + * @param string $storageFile Path to the file in which to store string information. |
|
| 945 | + * @return Localization_Scanner |
|
| 946 | + */ |
|
| 947 | 947 | public static function createScanner() : Localization_Scanner |
| 948 | 948 | { |
| 949 | 949 | self::requireConfiguration(); |
@@ -956,14 +956,14 @@ discard block |
||
| 956 | 956 | // FIXME: TODO: Add this |
| 957 | 957 | } |
| 958 | 958 | |
| 959 | - /** |
|
| 960 | - * Configures the localization for the application: |
|
| 961 | - * sets the location of the required files and folders. |
|
| 962 | - * Also updated the client library files as needed. |
|
| 963 | - * |
|
| 964 | - * @param string $storageFile Where to store the file analysis storage file. |
|
| 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 | - */ |
|
| 959 | + /** |
|
| 960 | + * Configures the localization for the application: |
|
| 961 | + * sets the location of the required files and folders. |
|
| 962 | + * Also updated the client library files as needed. |
|
| 963 | + * |
|
| 964 | + * @param string $storageFile Where to store the file analysis storage file. |
|
| 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 | + */ |
|
| 967 | 967 | public static function configure(string $storageFile, string $clientLibrariesFolder='') |
| 968 | 968 | { |
| 969 | 969 | self::$configured = true; |
@@ -979,17 +979,17 @@ discard block |
||
| 979 | 979 | } |
| 980 | 980 | } |
| 981 | 981 | |
| 982 | - /** |
|
| 983 | - * Sets a key that is used to verify whether the client |
|
| 984 | - * libraries have to be refreshed. A common use is to set |
|
| 985 | - * this to the application's version number to guarantee |
|
| 986 | - * new texts are automatically used with each release. |
|
| 987 | - * |
|
| 988 | - * NOTE: Otherwise files are refreshed only when saving |
|
| 989 | - * them in the editor UI. |
|
| 990 | - * |
|
| 991 | - * @param string $key |
|
| 992 | - */ |
|
| 982 | + /** |
|
| 983 | + * Sets a key that is used to verify whether the client |
|
| 984 | + * libraries have to be refreshed. A common use is to set |
|
| 985 | + * this to the application's version number to guarantee |
|
| 986 | + * new texts are automatically used with each release. |
|
| 987 | + * |
|
| 988 | + * NOTE: Otherwise files are refreshed only when saving |
|
| 989 | + * them in the editor UI. |
|
| 990 | + * |
|
| 991 | + * @param string $key |
|
| 992 | + */ |
|
| 993 | 993 | public static function setClientLibrariesCacheKey(string $key) |
| 994 | 994 | { |
| 995 | 995 | self::$clientCacheKey = $key; |
@@ -1000,48 +1000,48 @@ discard block |
||
| 1000 | 1000 | return self::$clientCacheKey; |
| 1001 | 1001 | } |
| 1002 | 1002 | |
| 1003 | - /** |
|
| 1004 | - * Sets the folder where client libraries are to be stored. |
|
| 1005 | - * @param string $folder |
|
| 1006 | - */ |
|
| 1003 | + /** |
|
| 1004 | + * Sets the folder where client libraries are to be stored. |
|
| 1005 | + * @param string $folder |
|
| 1006 | + */ |
|
| 1007 | 1007 | public static function setClientLibrariesFolder(string $folder) |
| 1008 | 1008 | { |
| 1009 | 1009 | self::$clientFolder = $folder; |
| 1010 | 1010 | } |
| 1011 | 1011 | |
| 1012 | - /** |
|
| 1013 | - * Retrieves the path to the folder in which the client |
|
| 1014 | - * libraries should be stored. |
|
| 1015 | - * |
|
| 1016 | - * NOTE: Can return an empty string, when this is disabled. |
|
| 1017 | - * |
|
| 1018 | - * @return string |
|
| 1019 | - */ |
|
| 1012 | + /** |
|
| 1013 | + * Retrieves the path to the folder in which the client |
|
| 1014 | + * libraries should be stored. |
|
| 1015 | + * |
|
| 1016 | + * NOTE: Can return an empty string, when this is disabled. |
|
| 1017 | + * |
|
| 1018 | + * @return string |
|
| 1019 | + */ |
|
| 1020 | 1020 | public static function getClientLibrariesFolder() : string |
| 1021 | 1021 | { |
| 1022 | 1022 | return self::$clientFolder; |
| 1023 | 1023 | } |
| 1024 | 1024 | |
| 1025 | - /** |
|
| 1026 | - * Writes / updates the client library files on disk, |
|
| 1027 | - * at the location specified in the {@link Localization::configure()} |
|
| 1028 | - * method. |
|
| 1029 | - * |
|
| 1030 | - * @see Localization_ClientGenerator |
|
| 1031 | - * @param bool $force Whether to refresh the files, even if they exist. |
|
| 1032 | - */ |
|
| 1025 | + /** |
|
| 1026 | + * Writes / updates the client library files on disk, |
|
| 1027 | + * at the location specified in the {@link Localization::configure()} |
|
| 1028 | + * method. |
|
| 1029 | + * |
|
| 1030 | + * @see Localization_ClientGenerator |
|
| 1031 | + * @param bool $force Whether to refresh the files, even if they exist. |
|
| 1032 | + */ |
|
| 1033 | 1033 | public static function writeClientFiles(bool $force=false) : void |
| 1034 | 1034 | { |
| 1035 | 1035 | self::createGenerator()->writeFiles($force); |
| 1036 | 1036 | } |
| 1037 | 1037 | |
| 1038 | - /** |
|
| 1039 | - * Creates a new instance of the client generator class |
|
| 1040 | - * that is used to write the localization files into the |
|
| 1041 | - * target folder on disk. |
|
| 1042 | - * |
|
| 1043 | - * @return Localization_ClientGenerator |
|
| 1044 | - */ |
|
| 1038 | + /** |
|
| 1039 | + * Creates a new instance of the client generator class |
|
| 1040 | + * that is used to write the localization files into the |
|
| 1041 | + * target folder on disk. |
|
| 1042 | + * |
|
| 1043 | + * @return Localization_ClientGenerator |
|
| 1044 | + */ |
|
| 1045 | 1045 | public static function createGenerator() : Localization_ClientGenerator |
| 1046 | 1046 | { |
| 1047 | 1047 | return new Localization_ClientGenerator(); |
@@ -1084,13 +1084,13 @@ discard block |
||
| 1084 | 1084 | } |
| 1085 | 1085 | } |
| 1086 | 1086 | |
| 1087 | - /** |
|
| 1088 | - * Creates the editor instance that can be used to |
|
| 1089 | - * display the localization UI to edit translateable |
|
| 1090 | - * strings in the browser. |
|
| 1091 | - * |
|
| 1092 | - * @return \AppLocalize\Localization_Editor |
|
| 1093 | - */ |
|
| 1087 | + /** |
|
| 1088 | + * Creates the editor instance that can be used to |
|
| 1089 | + * display the localization UI to edit translateable |
|
| 1090 | + * strings in the browser. |
|
| 1091 | + * |
|
| 1092 | + * @return \AppLocalize\Localization_Editor |
|
| 1093 | + */ |
|
| 1094 | 1094 | public static function createEditor() |
| 1095 | 1095 | { |
| 1096 | 1096 | self::requireConfiguration(); |
@@ -1098,10 +1098,10 @@ discard block |
||
| 1098 | 1098 | return new Localization_Editor(); |
| 1099 | 1099 | } |
| 1100 | 1100 | |
| 1101 | - /** |
|
| 1102 | - * Retrieves a list of all available source IDs. |
|
| 1103 | - * @return string[] |
|
| 1104 | - */ |
|
| 1101 | + /** |
|
| 1102 | + * Retrieves a list of all available source IDs. |
|
| 1103 | + * @return string[] |
|
| 1104 | + */ |
|
| 1105 | 1105 | public static function getSourceIDs() |
| 1106 | 1106 | { |
| 1107 | 1107 | $ids = array(); |
@@ -1128,9 +1128,9 @@ discard block |
||
| 1128 | 1128 | return $aliases; |
| 1129 | 1129 | } |
| 1130 | 1130 | |
| 1131 | - /** |
|
| 1132 | - * Resets all locales to the built-in locale. |
|
| 1133 | - */ |
|
| 1131 | + /** |
|
| 1132 | + * Resets all locales to the built-in locale. |
|
| 1133 | + */ |
|
| 1134 | 1134 | public static function reset() |
| 1135 | 1135 | { |
| 1136 | 1136 | self::$locales = array(); |
@@ -1162,22 +1162,22 @@ discard block |
||
| 1162 | 1162 | 'de_CH' |
| 1163 | 1163 | ); |
| 1164 | 1164 | |
| 1165 | - /** |
|
| 1166 | - * Retrieves a list of all supported locales. |
|
| 1167 | - * |
|
| 1168 | - * @return array |
|
| 1169 | - */ |
|
| 1165 | + /** |
|
| 1166 | + * Retrieves a list of all supported locales. |
|
| 1167 | + * |
|
| 1168 | + * @return array |
|
| 1169 | + */ |
|
| 1170 | 1170 | public static function getSupportedLocaleNames() : array |
| 1171 | 1171 | { |
| 1172 | 1172 | return self::$supportedLocales; |
| 1173 | 1173 | } |
| 1174 | 1174 | |
| 1175 | - /** |
|
| 1176 | - * Checks whether the specified locale is supported. |
|
| 1177 | - * |
|
| 1178 | - * @param string $localeName |
|
| 1179 | - * @return bool |
|
| 1180 | - */ |
|
| 1175 | + /** |
|
| 1176 | + * Checks whether the specified locale is supported. |
|
| 1177 | + * |
|
| 1178 | + * @param string $localeName |
|
| 1179 | + * @return bool |
|
| 1180 | + */ |
|
| 1181 | 1181 | public static function isLocaleSupported(string $localeName) : bool |
| 1182 | 1182 | { |
| 1183 | 1183 | return in_array($localeName, self::$supportedLocales); |
@@ -45,9 +45,9 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | private $targetLocaleName = null; |
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * @var Localization_Source[] |
|
| 50 | - */ |
|
| 48 | + /** |
|
| 49 | + * @var Localization_Source[] |
|
| 50 | + */ |
|
| 51 | 51 | private $sources = array(); |
| 52 | 52 | |
| 53 | 53 | public function addSource(Localization_Source $source) |
@@ -174,14 +174,14 @@ discard block |
||
| 174 | 174 | ); |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | - /** |
|
| 178 | - * Retrieves all available strings for the specified locale, |
|
| 179 | - * as hash => text value pairs. |
|
| 180 | - * |
|
| 181 | - * @param Localization_Locale $locale |
|
| 182 | - * @throws Localization_Exception |
|
| 183 | - * @return string[] |
|
| 184 | - */ |
|
| 177 | + /** |
|
| 178 | + * Retrieves all available strings for the specified locale, |
|
| 179 | + * as hash => text value pairs. |
|
| 180 | + * |
|
| 181 | + * @param Localization_Locale $locale |
|
| 182 | + * @throws Localization_Exception |
|
| 183 | + * @return string[] |
|
| 184 | + */ |
|
| 185 | 185 | public function getStrings(Localization_Locale $locale) |
| 186 | 186 | { |
| 187 | 187 | $this->load($locale); |
@@ -210,14 +210,14 @@ discard block |
||
| 210 | 210 | return !empty($this->strings[$locale->getName()]); |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | - /** |
|
| 214 | - * @param string $type |
|
| 215 | - * @param Localization_Scanner_StringHash[] $hashes |
|
| 216 | - * @param string $file |
|
| 217 | - * @param Localization_Locale $locale |
|
| 218 | - * @param boolean $editable |
|
| 219 | - * @throws Localization_Exception |
|
| 220 | - */ |
|
| 213 | + /** |
|
| 214 | + * @param string $type |
|
| 215 | + * @param Localization_Scanner_StringHash[] $hashes |
|
| 216 | + * @param string $file |
|
| 217 | + * @param Localization_Locale $locale |
|
| 218 | + * @param boolean $editable |
|
| 219 | + * @throws Localization_Exception |
|
| 220 | + */ |
|
| 221 | 221 | protected function renderStringsFile($type, Localization_Source $source, $hashes, $file, Localization_Locale $locale, $editable=true) |
| 222 | 222 | { |
| 223 | 223 | $sourceID = $source->getID(); |
@@ -280,16 +280,16 @@ discard block |
||
| 280 | 280 | } |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | - /** |
|
| 284 | - * Sort the strings to ensure they always appear in the same order: |
|
| 285 | - * first by text, and same strings by their hashes. This is important |
|
| 286 | - * for strings that have the same translation to avoid them changing |
|
| 287 | - * order between sorts. |
|
| 288 | - * |
|
| 289 | - * @param array $a |
|
| 290 | - * @param array $b |
|
| 291 | - * @return number |
|
| 292 | - */ |
|
| 283 | + /** |
|
| 284 | + * Sort the strings to ensure they always appear in the same order: |
|
| 285 | + * first by text, and same strings by their hashes. This is important |
|
| 286 | + * for strings that have the same translation to avoid them changing |
|
| 287 | + * order between sorts. |
|
| 288 | + * |
|
| 289 | + * @param array $a |
|
| 290 | + * @param array $b |
|
| 291 | + * @return number |
|
| 292 | + */ |
|
| 293 | 293 | public function callback_sortStrings($a, $b) |
| 294 | 294 | { |
| 295 | 295 | $result = strnatcasecmp($a['text'], $b['text']); |
@@ -316,13 +316,13 @@ discard block |
||
| 316 | 316 | ); |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | - /** |
|
| 320 | - * Retrieves the full path to the strings storage ini file |
|
| 321 | - * for the clientside strings. |
|
| 322 | - * |
|
| 323 | - * @param Localization_Locale $locale |
|
| 324 | - * @return string |
|
| 325 | - */ |
|
| 319 | + /** |
|
| 320 | + * Retrieves the full path to the strings storage ini file |
|
| 321 | + * for the clientside strings. |
|
| 322 | + * |
|
| 323 | + * @param Localization_Locale $locale |
|
| 324 | + * @return string |
|
| 325 | + */ |
|
| 326 | 326 | protected function getClientStorageFile(Localization_Locale $locale, Localization_Source $source) |
| 327 | 327 | { |
| 328 | 328 | return sprintf( |
@@ -444,12 +444,12 @@ discard block |
||
| 444 | 444 | return null; |
| 445 | 445 | } |
| 446 | 446 | |
| 447 | - /** |
|
| 448 | - * Retrieves only the strings that are available clientside. |
|
| 449 | - * |
|
| 450 | - * @param Localization_Locale $locale |
|
| 451 | - * @return array |
|
| 452 | - */ |
|
| 447 | + /** |
|
| 448 | + * Retrieves only the strings that are available clientside. |
|
| 449 | + * |
|
| 450 | + * @param Localization_Locale $locale |
|
| 451 | + * @return array |
|
| 452 | + */ |
|
| 453 | 453 | public function getClientStrings(Localization_Locale $locale) |
| 454 | 454 | { |
| 455 | 455 | $result = array(); |
@@ -10,19 +10,19 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | const STORAGE_FORMAT_VERSION = 1; |
| 12 | 12 | |
| 13 | - /** |
|
| 14 | - * @var Localization_Scanner |
|
| 15 | - */ |
|
| 13 | + /** |
|
| 14 | + * @var Localization_Scanner |
|
| 15 | + */ |
|
| 16 | 16 | protected $scanner; |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * @var Localization_Scanner_StringHash[] |
|
| 20 | - */ |
|
| 18 | + /** |
|
| 19 | + * @var Localization_Scanner_StringHash[] |
|
| 20 | + */ |
|
| 21 | 21 | protected $hashes = array(); |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * @var array |
|
| 25 | - */ |
|
| 23 | + /** |
|
| 24 | + * @var array |
|
| 25 | + */ |
|
| 26 | 26 | protected $warnings = array(); |
| 27 | 27 | |
| 28 | 28 | public function __construct(Localization_Scanner $scanner) |
@@ -51,12 +51,12 @@ discard block |
||
| 51 | 51 | return $string; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Adds a single translateable string. |
|
| 56 | - * |
|
| 57 | - * @param Localization_Scanner_StringInfo $string |
|
| 58 | - * @return Localization_Scanner_StringsCollection |
|
| 59 | - */ |
|
| 54 | + /** |
|
| 55 | + * Adds a single translateable string. |
|
| 56 | + * |
|
| 57 | + * @param Localization_Scanner_StringInfo $string |
|
| 58 | + * @return Localization_Scanner_StringsCollection |
|
| 59 | + */ |
|
| 60 | 60 | protected function add(Localization_Scanner_StringInfo $string) |
| 61 | 61 | { |
| 62 | 62 | $hash = $string->getHash(); |
@@ -69,12 +69,12 @@ discard block |
||
| 69 | 69 | return $this; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * Retrieves all available translateable strings, |
|
| 74 | - * grouped by their hash to identify unique strings. |
|
| 75 | - * |
|
| 76 | - * @return Localization_Scanner_StringHash[] |
|
| 77 | - */ |
|
| 72 | + /** |
|
| 73 | + * Retrieves all available translateable strings, |
|
| 74 | + * grouped by their hash to identify unique strings. |
|
| 75 | + * |
|
| 76 | + * @return Localization_Scanner_StringHash[] |
|
| 77 | + */ |
|
| 78 | 78 | public function getHashes() |
| 79 | 79 | { |
| 80 | 80 | return array_values($this->hashes); |
@@ -133,32 +133,32 @@ discard block |
||
| 133 | 133 | return true; |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - /** |
|
| 137 | - * Whether the parser reported warnings during the |
|
| 138 | - * search for translateable texts. |
|
| 139 | - * |
|
| 140 | - * @return bool |
|
| 141 | - */ |
|
| 136 | + /** |
|
| 137 | + * Whether the parser reported warnings during the |
|
| 138 | + * search for translateable texts. |
|
| 139 | + * |
|
| 140 | + * @return bool |
|
| 141 | + */ |
|
| 142 | 142 | public function hasWarnings() : bool |
| 143 | 143 | { |
| 144 | 144 | return !empty($this->warnings); |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - /** |
|
| 148 | - * Retrieves the amount of warnings. |
|
| 149 | - * @return int |
|
| 150 | - */ |
|
| 147 | + /** |
|
| 148 | + * Retrieves the amount of warnings. |
|
| 149 | + * @return int |
|
| 150 | + */ |
|
| 151 | 151 | public function countWarnings() : int |
| 152 | 152 | { |
| 153 | 153 | return count($this->warnings); |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - /** |
|
| 157 | - * Retrieves all warning messages that were added |
|
| 158 | - * during the search for translateable texts, if any. |
|
| 159 | - * |
|
| 160 | - * @return Localization_Scanner_StringsCollection_Warning[] |
|
| 161 | - */ |
|
| 156 | + /** |
|
| 157 | + * Retrieves all warning messages that were added |
|
| 158 | + * during the search for translateable texts, if any. |
|
| 159 | + * |
|
| 160 | + * @return Localization_Scanner_StringsCollection_Warning[] |
|
| 161 | + */ |
|
| 162 | 162 | public function getWarnings() : array |
| 163 | 163 | { |
| 164 | 164 | $result = array(); |
@@ -185,12 +185,12 @@ discard block |
||
| 185 | 185 | return $amount; |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | - /** |
|
| 189 | - * Retrieves all string hashed for the specified source. |
|
| 190 | - * |
|
| 191 | - * @param string $id |
|
| 192 | - * @return \AppLocalize\Localization_Scanner_StringHash[] |
|
| 193 | - */ |
|
| 188 | + /** |
|
| 189 | + * Retrieves all string hashed for the specified source. |
|
| 190 | + * |
|
| 191 | + * @param string $id |
|
| 192 | + * @return \AppLocalize\Localization_Scanner_StringHash[] |
|
| 193 | + */ |
|
| 194 | 194 | public function getHashesBySourceID(string $id) |
| 195 | 195 | { |
| 196 | 196 | $hashes = array(); |
@@ -204,12 +204,12 @@ discard block |
||
| 204 | 204 | return $hashes; |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | - /** |
|
| 208 | - * Retrieves all hashes for the specified language ID. |
|
| 209 | - * |
|
| 210 | - * @param string $languageID The language ID, e.g. "PHP" |
|
| 211 | - * @return \AppLocalize\Localization_Scanner_StringHash[] |
|
| 212 | - */ |
|
| 207 | + /** |
|
| 208 | + * Retrieves all hashes for the specified language ID. |
|
| 209 | + * |
|
| 210 | + * @param string $languageID The language ID, e.g. "PHP" |
|
| 211 | + * @return \AppLocalize\Localization_Scanner_StringHash[] |
|
| 212 | + */ |
|
| 213 | 213 | public function getHashesByLanguageID(string $languageID) |
| 214 | 214 | { |
| 215 | 215 | $hashes = array(); |
@@ -4,9 +4,9 @@ |
||
| 4 | 4 | |
| 5 | 5 | class Localization_Scanner_StringInfo |
| 6 | 6 | { |
| 7 | - /** |
|
| 8 | - * @var Localization_Scanner_StringsCollection |
|
| 9 | - */ |
|
| 7 | + /** |
|
| 8 | + * @var Localization_Scanner_StringsCollection |
|
| 9 | + */ |
|
| 10 | 10 | protected $collection; |
| 11 | 11 | |
| 12 | 12 | protected $properties = array(); |
@@ -13,19 +13,19 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | class Localization_Scanner_StringHash |
| 15 | 15 | { |
| 16 | - /** |
|
| 17 | - * @var Localization_Scanner_StringsCollection |
|
| 18 | - */ |
|
| 16 | + /** |
|
| 17 | + * @var Localization_Scanner_StringsCollection |
|
| 18 | + */ |
|
| 19 | 19 | protected $collection; |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @var string |
|
| 23 | - */ |
|
| 21 | + /** |
|
| 22 | + * @var string |
|
| 23 | + */ |
|
| 24 | 24 | protected $hash; |
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * @var Localization_Scanner_StringInfo[] |
|
| 28 | - */ |
|
| 26 | + /** |
|
| 27 | + * @var Localization_Scanner_StringInfo[] |
|
| 28 | + */ |
|
| 29 | 29 | protected $strings = array(); |
| 30 | 30 | |
| 31 | 31 | protected $sourceIDs = array(); |
@@ -55,10 +55,10 @@ discard block |
||
| 55 | 55 | return $entries; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * Retrieves all individual string locations where this text was found. |
|
| 60 | - * @return Localization_Scanner_StringInfo[] |
|
| 61 | - */ |
|
| 58 | + /** |
|
| 59 | + * Retrieves all individual string locations where this text was found. |
|
| 60 | + * @return Localization_Scanner_StringInfo[] |
|
| 61 | + */ |
|
| 62 | 62 | public function getStrings() |
| 63 | 63 | { |
| 64 | 64 | return $this->strings; |
@@ -118,10 +118,10 @@ discard block |
||
| 118 | 118 | return count($this->strings); |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - /** |
|
| 122 | - * Retrieves the translated text, if any. |
|
| 123 | - * @return string|NULL |
|
| 124 | - */ |
|
| 121 | + /** |
|
| 122 | + * Retrieves the translated text, if any. |
|
| 123 | + * @return string|NULL |
|
| 124 | + */ |
|
| 125 | 125 | public function getTranslatedText() : string |
| 126 | 126 | { |
| 127 | 127 | $translator = Localization::getTranslator(); |
@@ -134,10 +134,10 @@ discard block |
||
| 134 | 134 | return ''; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - /** |
|
| 138 | - * Retrieves a list of all file names, with relative paths. |
|
| 139 | - * @return string[] |
|
| 140 | - */ |
|
| 137 | + /** |
|
| 138 | + * Retrieves a list of all file names, with relative paths. |
|
| 139 | + * @return string[] |
|
| 140 | + */ |
|
| 141 | 141 | public function getFiles() : array |
| 142 | 142 | { |
| 143 | 143 | $files = array(); |
@@ -159,10 +159,10 @@ discard block |
||
| 159 | 159 | return $files; |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - /** |
|
| 163 | - * Retrieves a list of all file names this string is used in. |
|
| 164 | - * @return string[] |
|
| 165 | - */ |
|
| 162 | + /** |
|
| 163 | + * Retrieves a list of all file names this string is used in. |
|
| 164 | + * @return string[] |
|
| 165 | + */ |
|
| 166 | 166 | public function getFileNames() : array |
| 167 | 167 | { |
| 168 | 168 | $files = $this->getFiles(); |
@@ -179,13 +179,13 @@ discard block |
||
| 179 | 179 | return $result; |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | - /** |
|
| 183 | - * Retrieves a text comprised of all strings that are relevant |
|
| 184 | - * for a full text search, imploded together. Used in the search |
|
| 185 | - * function to find matching strings. |
|
| 186 | - * |
|
| 187 | - * @return string |
|
| 188 | - */ |
|
| 182 | + /** |
|
| 183 | + * Retrieves a text comprised of all strings that are relevant |
|
| 184 | + * for a full text search, imploded together. Used in the search |
|
| 185 | + * function to find matching strings. |
|
| 186 | + * |
|
| 187 | + * @return string |
|
| 188 | + */ |
|
| 189 | 189 | public function getSearchString() : string |
| 190 | 190 | { |
| 191 | 191 | $parts = array($this->getTranslatedText(), $this->getText()); |
@@ -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) |
@@ -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); |
@@ -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])) { |