@@ -8,15 +8,13 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | namespace GravityKit\GravityView\Foundation\ThirdParty\Gettext\Languages\Exporter; |
| 10 | 10 | |
| 11 | -class Xml extends Exporter |
|
| 12 | -{ |
|
| 11 | +class Xml extends Exporter { |
|
| 13 | 12 | /** |
| 14 | 13 | * {@inheritdoc} |
| 15 | 14 | * |
| 16 | 15 | * @see \GravityKit\GravityView\Foundation\ThirdParty\Gettext\Languages\Exporter\Exporter::getDescription() |
| 17 | 16 | */ |
| 18 | - public static function getDescription() |
|
| 19 | - { |
|
| 17 | + public static function getDescription() { |
|
| 20 | 18 | return 'Build an XML file - schema available at http://mlocati.github.io/cldr-to-gettext-plural-rules/GettextLanguages.xsd'; |
| 21 | 19 | } |
| 22 | 20 | |
@@ -25,8 +23,7 @@ discard block |
||
| 25 | 23 | * |
| 26 | 24 | * @see \GravityKit\GravityView\Foundation\ThirdParty\Gettext\Languages\Exporter\Exporter::toStringDo() |
| 27 | 25 | */ |
| 28 | - protected static function toStringDo($languages) |
|
| 29 | - { |
|
| 26 | + protected static function toStringDo($languages) { |
|
| 30 | 27 | $xml = new \DOMDocument('1.0', 'UTF-8'); |
| 31 | 28 | $xml->loadXML('<languages |
| 32 | 29 | xmlns="https://github.com/mlocati/cldr-to-gettext-plural-rules" |
@@ -10,15 +10,13 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | use Exception; |
| 12 | 12 | |
| 13 | -class Prettyjson extends Json |
|
| 14 | -{ |
|
| 13 | +class Prettyjson extends Json { |
|
| 15 | 14 | /** |
| 16 | 15 | * {@inheritdoc} |
| 17 | 16 | * |
| 18 | 17 | * @see \GravityKit\GravityView\Foundation\ThirdParty\Gettext\Languages\Exporter\Exporter::getDescription() |
| 19 | 18 | */ |
| 20 | - public static function getDescription() |
|
| 21 | - { |
|
| 19 | + public static function getDescription() { |
|
| 22 | 20 | return 'Build an uncompressed JSON-encoded file (PHP 5.4 or later is needed)'; |
| 23 | 21 | } |
| 24 | 22 | |
@@ -27,8 +25,7 @@ discard block |
||
| 27 | 25 | * |
| 28 | 26 | * @see \GravityKit\GravityView\Foundation\ThirdParty\Gettext\Languages\Exporter\Json::getEncodeOptions() |
| 29 | 27 | */ |
| 30 | - protected static function getEncodeOptions() |
|
| 31 | - { |
|
| 28 | + protected static function getEncodeOptions() { |
|
| 32 | 29 | if (!(defined('\JSON_PRETTY_PRINT') && defined('\JSON_UNESCAPED_SLASHES') && defined('\JSON_UNESCAPED_UNICODE'))) { |
| 33 | 30 | throw new Exception('PHP 5.4 or later is required to export uncompressed JSON'); |
| 34 | 31 | } |
@@ -8,15 +8,13 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | namespace GravityKit\GravityView\Foundation\ThirdParty\Gettext\Languages\Exporter; |
| 10 | 10 | |
| 11 | -class Html extends Exporter |
|
| 12 | -{ |
|
| 11 | +class Html extends Exporter { |
|
| 13 | 12 | /** |
| 14 | 13 | * {@inheritdoc} |
| 15 | 14 | * |
| 16 | 15 | * @see \GravityKit\GravityView\Foundation\ThirdParty\Gettext\Languages\Exporter\Exporter::getDescription() |
| 17 | 16 | */ |
| 18 | - public static function getDescription() |
|
| 19 | - { |
|
| 17 | + public static function getDescription() { |
|
| 20 | 18 | return 'Build a HTML table'; |
| 21 | 19 | } |
| 22 | 20 | |
@@ -25,18 +23,15 @@ discard block |
||
| 25 | 23 | * |
| 26 | 24 | * @see \GravityKit\GravityView\Foundation\ThirdParty\Gettext\Languages\Exporter\Exporter::toStringDo() |
| 27 | 25 | */ |
| 28 | - protected static function toStringDo($languages) |
|
| 29 | - { |
|
| 26 | + protected static function toStringDo($languages) { |
|
| 30 | 27 | return self::buildTable($languages, false); |
| 31 | 28 | } |
| 32 | 29 | |
| 33 | - protected static function h($str) |
|
| 34 | - { |
|
| 30 | + protected static function h($str) { |
|
| 35 | 31 | return htmlspecialchars($str, ENT_COMPAT, 'UTF-8'); |
| 36 | 32 | } |
| 37 | 33 | |
| 38 | - protected static function buildTable($languages, $forDocs) |
|
| 39 | - { |
|
| 34 | + protected static function buildTable($languages, $forDocs) { |
|
| 40 | 35 | $prefix = $forDocs ? ' ' : ''; |
| 41 | 36 | $lines = array(); |
| 42 | 37 | $lines[] = $prefix . '<table' . ($forDocs ? ' class="table table-bordered table-condensed table-striped"' : '') . '>'; |
@@ -10,15 +10,13 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | use Exception; |
| 12 | 12 | |
| 13 | -class Po extends Exporter |
|
| 14 | -{ |
|
| 13 | +class Po extends Exporter { |
|
| 15 | 14 | /** |
| 16 | 15 | * {@inheritdoc} |
| 17 | 16 | * |
| 18 | 17 | * @see \GravityKit\GravityView\Foundation\ThirdParty\Gettext\Languages\Exporter\Exporter::getDescription() |
| 19 | 18 | */ |
| 20 | - public static function getDescription() |
|
| 21 | - { |
|
| 19 | + public static function getDescription() { |
|
| 22 | 20 | return 'Build a string to be used for gettext .po files'; |
| 23 | 21 | } |
| 24 | 22 | |
@@ -27,8 +25,7 @@ discard block |
||
| 27 | 25 | * |
| 28 | 26 | * @see \GravityKit\GravityView\Foundation\ThirdParty\Gettext\Languages\Exporter\Exporter::toStringDo() |
| 29 | 27 | */ |
| 30 | - protected static function toStringDo($languages) |
|
| 31 | - { |
|
| 28 | + protected static function toStringDo($languages) { |
|
| 32 | 29 | if (count($languages) !== 1) { |
| 33 | 30 | throw new Exception('The ' . get_called_class() . ' exporter can only export one language'); |
| 34 | 31 | } |
@@ -8,15 +8,13 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | namespace GravityKit\GravityView\Foundation\ThirdParty\Gettext\Languages\Exporter; |
| 10 | 10 | |
| 11 | -class Php extends Exporter |
|
| 12 | -{ |
|
| 11 | +class Php extends Exporter { |
|
| 13 | 12 | /** |
| 14 | 13 | * {@inheritdoc} |
| 15 | 14 | * |
| 16 | 15 | * @see \GravityKit\GravityView\Foundation\ThirdParty\Gettext\Languages\Exporter\Exporter::getDescription() |
| 17 | 16 | */ |
| 18 | - public static function getDescription() |
|
| 19 | - { |
|
| 17 | + public static function getDescription() { |
|
| 20 | 18 | return 'Build a PHP array'; |
| 21 | 19 | } |
| 22 | 20 | |
@@ -25,8 +23,7 @@ discard block |
||
| 25 | 23 | * |
| 26 | 24 | * @see \GravityKit\GravityView\Foundation\ThirdParty\Gettext\Languages\Exporter\Exporter::toStringDo() |
| 27 | 25 | */ |
| 28 | - protected static function toStringDo($languages) |
|
| 29 | - { |
|
| 26 | + protected static function toStringDo($languages) { |
|
| 30 | 27 | $lines = array(); |
| 31 | 28 | $lines[] = '<?php'; |
| 32 | 29 | $lines[] = 'return array('; |
@@ -8,15 +8,13 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | namespace GravityKit\GravityView\Foundation\ThirdParty\Gettext\Languages\Exporter; |
| 10 | 10 | |
| 11 | -class Ruby extends Exporter |
|
| 12 | -{ |
|
| 11 | +class Ruby extends Exporter { |
|
| 13 | 12 | /** |
| 14 | 13 | * {@inheritdoc} |
| 15 | 14 | * |
| 16 | 15 | * @see \GravityKit\GravityView\Foundation\ThirdParty\Gettext\Languages\Exporter\Exporter::getDescription() |
| 17 | 16 | */ |
| 18 | - public static function getDescription() |
|
| 19 | - { |
|
| 17 | + public static function getDescription() { |
|
| 20 | 18 | return 'Build a Ruby hash'; |
| 21 | 19 | } |
| 22 | 20 | |
@@ -25,8 +23,7 @@ discard block |
||
| 25 | 23 | * |
| 26 | 24 | * @see \GravityKit\GravityView\Foundation\ThirdParty\Gettext\Languages\Exporter\Exporter::toStringDo() |
| 27 | 25 | */ |
| 28 | - protected static function toStringDo($languages) |
|
| 29 | - { |
|
| 26 | + protected static function toStringDo($languages) { |
|
| 30 | 27 | $lines = array(); |
| 31 | 28 | $lines[] = 'PLURAL_RULES = {'; |
| 32 | 29 | foreach ($languages as $lc) { |
@@ -8,15 +8,13 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | namespace GravityKit\GravityView\Foundation\ThirdParty\Gettext\Languages\Exporter; |
| 10 | 10 | |
| 11 | -class Json extends Exporter |
|
| 12 | -{ |
|
| 11 | +class Json extends Exporter { |
|
| 13 | 12 | /** |
| 14 | 13 | * {@inheritdoc} |
| 15 | 14 | * |
| 16 | 15 | * @see \GravityKit\GravityView\Foundation\ThirdParty\Gettext\Languages\Exporter\Exporter::getDescription() |
| 17 | 16 | */ |
| 18 | - public static function getDescription() |
|
| 19 | - { |
|
| 17 | + public static function getDescription() { |
|
| 20 | 18 | return 'Build a compressed JSON-encoded file'; |
| 21 | 19 | } |
| 22 | 20 | |
@@ -25,8 +23,7 @@ discard block |
||
| 25 | 23 | * |
| 26 | 24 | * @return int |
| 27 | 25 | */ |
| 28 | - protected static function getEncodeOptions() |
|
| 29 | - { |
|
| 26 | + protected static function getEncodeOptions() { |
|
| 30 | 27 | $result = 0; |
| 31 | 28 | if (defined('\JSON_UNESCAPED_SLASHES')) { |
| 32 | 29 | $result |= \JSON_UNESCAPED_SLASHES; |
@@ -43,8 +40,7 @@ discard block |
||
| 43 | 40 | * |
| 44 | 41 | * @see \GravityKit\GravityView\Foundation\ThirdParty\Gettext\Languages\Exporter\Exporter::toStringDo() |
| 45 | 42 | */ |
| 46 | - protected static function toStringDo($languages) |
|
| 47 | - { |
|
| 43 | + protected static function toStringDo($languages) { |
|
| 48 | 44 | $list = array(); |
| 49 | 45 | foreach ($languages as $language) { |
| 50 | 46 | $item = array(); |
@@ -8,15 +8,13 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | namespace GravityKit\GravityView\Foundation\ThirdParty\Gettext\Languages\Exporter; |
| 10 | 10 | |
| 11 | -class Docs extends Html |
|
| 12 | -{ |
|
| 11 | +class Docs extends Html { |
|
| 13 | 12 | /** |
| 14 | 13 | * {@inheritdoc} |
| 15 | 14 | * |
| 16 | 15 | * @see \GravityKit\GravityView\Foundation\ThirdParty\Gettext\Languages\Exporter\Exporter::isForPublicUse() |
| 17 | 16 | */ |
| 18 | - public static function isForPublicUse() |
|
| 19 | - { |
|
| 17 | + public static function isForPublicUse() { |
|
| 20 | 18 | return false; |
| 21 | 19 | } |
| 22 | 20 | |
@@ -25,8 +23,7 @@ discard block |
||
| 25 | 23 | * |
| 26 | 24 | * @see \GravityKit\GravityView\Foundation\ThirdParty\Gettext\Languages\Exporter\Exporter::getDescription() |
| 27 | 25 | */ |
| 28 | - public static function getDescription() |
|
| 29 | - { |
|
| 26 | + public static function getDescription() { |
|
| 30 | 27 | return 'Build the page https://php-gettext.github.io/Languages/'; |
| 31 | 28 | } |
| 32 | 29 | |
@@ -35,8 +32,7 @@ discard block |
||
| 35 | 32 | * |
| 36 | 33 | * @see \GravityKit\GravityView\Foundation\ThirdParty\Gettext\Languages\Exporter\Exporter::toStringDo() |
| 37 | 34 | */ |
| 38 | - protected static function toStringDo($languages) |
|
| 39 | - { |
|
| 35 | + protected static function toStringDo($languages) { |
|
| 40 | 36 | $result = <<<'EOT' |
| 41 | 37 | <!doctype html> |
| 42 | 38 | <html lang="en"> |
@@ -13,8 +13,7 @@ discard block |
||
| 13 | 13 | /** |
| 14 | 14 | * Main class to convert the plural rules of a language from CLDR to gettext. |
| 15 | 15 | */ |
| 16 | -class Language |
|
| 17 | -{ |
|
| 16 | +class Language { |
|
| 18 | 17 | /** |
| 19 | 18 | * The language ID. |
| 20 | 19 | * |
@@ -78,8 +77,7 @@ discard block |
||
| 78 | 77 | * |
| 79 | 78 | * @throws \Exception throws an Exception if $fullId is not valid |
| 80 | 79 | */ |
| 81 | - private function __construct($info) |
|
| 82 | - { |
|
| 80 | + private function __construct($info) { |
|
| 83 | 81 | $this->id = $info['id']; |
| 84 | 82 | $this->name = $info['name']; |
| 85 | 83 | $this->supersededBy = isset($info['supersededBy']) ? $info['supersededBy'] : null; |
@@ -121,8 +119,7 @@ discard block |
||
| 121 | 119 | * |
| 122 | 120 | * @return \GravityKit\GravityView\Foundation\ThirdParty\Gettext\Languages\Language[] |
| 123 | 121 | */ |
| 124 | - public static function getAll() |
|
| 125 | - { |
|
| 122 | + public static function getAll() { |
|
| 126 | 123 | $result = array(); |
| 127 | 124 | foreach (array_keys(CldrData::getLanguageNames()) as $cldrLanguageId) { |
| 128 | 125 | $result[] = new self(CldrData::getLanguageInfo($cldrLanguageId)); |
@@ -138,8 +135,7 @@ discard block |
||
| 138 | 135 | * |
| 139 | 136 | * @return \GravityKit\GravityView\Foundation\ThirdParty\Gettext\Languages\Language|null |
| 140 | 137 | */ |
| 141 | - public static function getById($id) |
|
| 142 | - { |
|
| 138 | + public static function getById($id) { |
|
| 143 | 139 | $result = null; |
| 144 | 140 | $info = CldrData::getLanguageInfo($id); |
| 145 | 141 | if (isset($info)) { |
@@ -154,8 +150,7 @@ discard block |
||
| 154 | 150 | * |
| 155 | 151 | * @return \GravityKit\GravityView\Foundation\ThirdParty\Gettext\Languages\Language |
| 156 | 152 | */ |
| 157 | - public function getUSAsciiClone() |
|
| 158 | - { |
|
| 153 | + public function getUSAsciiClone() { |
|
| 159 | 154 | $clone = clone $this; |
| 160 | 155 | self::asciifier($clone->name); |
| 161 | 156 | self::asciifier($clone->formula); |
@@ -176,8 +171,7 @@ discard block |
||
| 176 | 171 | * |
| 177 | 172 | * @return string |
| 178 | 173 | */ |
| 179 | - public function buildFormula($withoutParenthesis = false) |
|
| 180 | - { |
|
| 174 | + public function buildFormula($withoutParenthesis = false) { |
|
| 181 | 175 | $numCategories = count($this->categories); |
| 182 | 176 | switch ($numCategories) { |
| 183 | 177 | case 1: |
@@ -209,8 +203,7 @@ discard block |
||
| 209 | 203 | * |
| 210 | 204 | * @throws \Exception |
| 211 | 205 | */ |
| 212 | - private function checkAlwaysTrueCategories() |
|
| 213 | - { |
|
| 206 | + private function checkAlwaysTrueCategories() { |
|
| 214 | 207 | $alwaysTrueCategory = null; |
| 215 | 208 | foreach ($this->categories as $category) { |
| 216 | 209 | if ($category->formula === true) { |
@@ -240,8 +233,7 @@ discard block |
||
| 240 | 233 | * |
| 241 | 234 | * @throws \Exception |
| 242 | 235 | */ |
| 243 | - private function checkAlwaysFalseCategories() |
|
| 244 | - { |
|
| 236 | + private function checkAlwaysFalseCategories() { |
|
| 245 | 237 | $filtered = array(); |
| 246 | 238 | foreach ($this->categories as $category) { |
| 247 | 239 | if ($category->formula === false) { |
@@ -262,8 +254,7 @@ discard block |
||
| 262 | 254 | * |
| 263 | 255 | * @throws \Exception |
| 264 | 256 | */ |
| 265 | - private function checkAllCategoriesWithExamples() |
|
| 266 | - { |
|
| 257 | + private function checkAllCategoriesWithExamples() { |
|
| 267 | 258 | $allCategoriesIds = array(); |
| 268 | 259 | $goodCategories = array(); |
| 269 | 260 | $badCategories = array(); |
@@ -343,8 +334,7 @@ discard block |
||
| 343 | 334 | * |
| 344 | 335 | * @return string |
| 345 | 336 | */ |
| 346 | - private static function reverseFormula($formula) |
|
| 347 | - { |
|
| 337 | + private static function reverseFormula($formula) { |
|
| 348 | 338 | if (preg_match('/^n( % \d+)? == \d+(\.\.\d+|,\d+)*?$/', $formula)) { |
| 349 | 339 | return str_replace(' == ', ' != ', $formula); |
| 350 | 340 | } |
@@ -374,8 +364,7 @@ discard block |
||
| 374 | 364 | * |
| 375 | 365 | * @return string |
| 376 | 366 | */ |
| 377 | - private static function reduceFormula($formula) |
|
| 378 | - { |
|
| 367 | + private static function reduceFormula($formula) { |
|
| 379 | 368 | $map = array( |
| 380 | 369 | 'n != 0 && n != 1' => 'n > 1', |
| 381 | 370 | '(n == 0 || n == 1) && n != 0' => 'n == 1', |
@@ -391,8 +380,7 @@ discard block |
||
| 391 | 380 | * |
| 392 | 381 | * @throws \Exception |
| 393 | 382 | */ |
| 394 | - private static function asciifier(&$value) |
|
| 395 | - { |
|
| 383 | + private static function asciifier(&$value) { |
|
| 396 | 384 | if (is_string($value) && $value !== '') { |
| 397 | 385 | // Avoid converting from 'Ÿ' to '"Y', let's prefer 'Y' |
| 398 | 386 | $value = strtr($value, array( |