@@ -4,15 +4,13 @@ discard block |
||
4 | 4 | |
5 | 5 | use Exception; |
6 | 6 | |
7 | -class Prettyjson extends Json |
|
8 | -{ |
|
7 | +class Prettyjson extends Json { |
|
9 | 8 | /** |
10 | 9 | * {@inheritdoc} |
11 | 10 | * |
12 | 11 | * @see \Gettext\Languages\Exporter\Exporter::getDescription() |
13 | 12 | */ |
14 | - public static function getDescription() |
|
15 | - { |
|
13 | + public static function getDescription() { |
|
16 | 14 | return 'Build an uncompressed JSON-encoded file (PHP 5.4 or later is needed)'; |
17 | 15 | } |
18 | 16 | |
@@ -21,8 +19,7 @@ discard block |
||
21 | 19 | * |
22 | 20 | * @see \Gettext\Languages\Exporter\Json::getEncodeOptions() |
23 | 21 | */ |
24 | - protected static function getEncodeOptions() |
|
25 | - { |
|
22 | + protected static function getEncodeOptions() { |
|
26 | 23 | if (!(defined('\JSON_PRETTY_PRINT') && defined('\JSON_UNESCAPED_SLASHES') && defined('\JSON_UNESCAPED_UNICODE'))) { |
27 | 24 | throw new Exception('PHP 5.4 or later is required to export uncompressed JSON'); |
28 | 25 | } |
@@ -2,15 +2,13 @@ discard block |
||
2 | 2 | |
3 | 3 | namespace Gettext\Languages\Exporter; |
4 | 4 | |
5 | -class Ruby extends Exporter |
|
6 | -{ |
|
5 | +class Ruby extends Exporter { |
|
7 | 6 | /** |
8 | 7 | * {@inheritdoc} |
9 | 8 | * |
10 | 9 | * @see \Gettext\Languages\Exporter\Exporter::getDescription() |
11 | 10 | */ |
12 | - public static function getDescription() |
|
13 | - { |
|
11 | + public static function getDescription() { |
|
14 | 12 | return 'Build a Ruby hash'; |
15 | 13 | } |
16 | 14 | |
@@ -19,8 +17,7 @@ discard block |
||
19 | 17 | * |
20 | 18 | * @see \Gettext\Languages\Exporter\Exporter::toStringDo() |
21 | 19 | */ |
22 | - protected static function toStringDo($languages) |
|
23 | - { |
|
20 | + protected static function toStringDo($languages) { |
|
24 | 21 | $lines = array(); |
25 | 22 | $lines[] = 'PLURAL_RULES = {'; |
26 | 23 | foreach ($languages as $lc) { |
@@ -7,8 +7,7 @@ discard block |
||
7 | 7 | /** |
8 | 8 | * A helper class that handles a single category rules (eg 'zero', 'one', ...) and its formula and examples. |
9 | 9 | */ |
10 | -class Category |
|
11 | -{ |
|
10 | +class Category { |
|
12 | 11 | /** |
13 | 12 | * The category identifier (eg 'zero', 'one', ..., 'other'). |
14 | 13 | * |
@@ -38,8 +37,7 @@ discard block |
||
38 | 37 | * |
39 | 38 | * @throws \Exception |
40 | 39 | */ |
41 | - public function __construct($cldrCategoryId, $cldrFormulaAndExamples) |
|
42 | - { |
|
40 | + public function __construct($cldrCategoryId, $cldrFormulaAndExamples) { |
|
43 | 41 | $matches = array(); |
44 | 42 | if (!preg_match('/^pluralRule-count-(.+)$/', $cldrCategoryId, $matches)) { |
45 | 43 | throw new Exception("Invalid CLDR category: '{$cldrCategoryId}'"); |
@@ -78,8 +76,7 @@ discard block |
||
78 | 76 | * |
79 | 77 | * @return int[] |
80 | 78 | */ |
81 | - public function getExampleIntegers() |
|
82 | - { |
|
79 | + public function getExampleIntegers() { |
|
83 | 80 | return self::expandExamples($this->examples); |
84 | 81 | } |
85 | 82 | |
@@ -92,8 +89,7 @@ discard block |
||
92 | 89 | * |
93 | 90 | * @return int[] |
94 | 91 | */ |
95 | - public static function expandExamples($examples) |
|
96 | - { |
|
92 | + public static function expandExamples($examples) { |
|
97 | 93 | $result = array(); |
98 | 94 | $m = null; |
99 | 95 | if (substr($examples, -strlen(', …')) === ', …') { |
@@ -7,8 +7,7 @@ discard block |
||
7 | 7 | /** |
8 | 8 | * A helper class to convert a CLDR formula to a gettext formula. |
9 | 9 | */ |
10 | -class FormulaConverter |
|
11 | -{ |
|
10 | +class FormulaConverter { |
|
12 | 11 | /** |
13 | 12 | * Converts a formula from the CLDR representation to the gettext representation. |
14 | 13 | * |
@@ -18,8 +17,7 @@ discard block |
||
18 | 17 | * |
19 | 18 | * @return bool|string returns true if the gettext will always evaluate to true, false if gettext will always evaluate to false, return the gettext formula otherwise |
20 | 19 | */ |
21 | - public static function convertFormula($cldrFormula) |
|
22 | - { |
|
20 | + public static function convertFormula($cldrFormula) { |
|
23 | 21 | if (strpbrk($cldrFormula, '()') !== false) { |
24 | 22 | throw new Exception("Unable to convert the formula '{$cldrFormula}': parenthesis handling not implemented"); |
25 | 23 | } |
@@ -77,8 +75,7 @@ discard block |
||
77 | 75 | * |
78 | 76 | * @return bool|string returns true if the gettext will always evaluate to true, false if gettext will always evaluate to false, return the gettext formula otherwise |
79 | 77 | */ |
80 | - private static function convertAtom($cldrAtom) |
|
81 | - { |
|
78 | + private static function convertAtom($cldrAtom) { |
|
82 | 79 | $m = null; |
83 | 80 | $gettextAtom = $cldrAtom; |
84 | 81 | $gettextAtom = str_replace(' = ', ' == ', $gettextAtom); |
@@ -89,16 +86,20 @@ discard block |
||
89 | 86 | if (preg_match('/^n( % \d+)? (!=|==) \d+(,\d+|\.\.\d+)+$/', $gettextAtom)) { |
90 | 87 | return self::expandAtom($gettextAtom); |
91 | 88 | } |
92 | - if (preg_match('/^(?:v|w)(?: % 10+)? == (\d+)(?:\.\.\d+)?$/', $gettextAtom, $m)) { // For gettext: v == 0, w == 0 |
|
89 | + if (preg_match('/^(?:v|w)(?: % 10+)? == (\d+)(?:\.\.\d+)?$/', $gettextAtom, $m)) { |
|
90 | +// For gettext: v == 0, w == 0 |
|
93 | 91 | return (int) $m[1] === 0 ? true : false; |
94 | 92 | } |
95 | - if (preg_match('/^(?:v|w)(?: % 10+)? != (\d+)(?:\.\.\d+)?$/', $gettextAtom, $m)) { // For gettext: v == 0, w == 0 |
|
93 | + if (preg_match('/^(?:v|w)(?: % 10+)? != (\d+)(?:\.\.\d+)?$/', $gettextAtom, $m)) { |
|
94 | +// For gettext: v == 0, w == 0 |
|
96 | 95 | return (int) $m[1] === 0 ? false : true; |
97 | 96 | } |
98 | - if (preg_match('/^(?:f|t|c|e)(?: % 10+)? == (\d+)(?:\.\.\d+)?$/', $gettextAtom, $m)) { // f == empty, t == empty, c == empty, e == empty |
|
97 | + if (preg_match('/^(?:f|t|c|e)(?: % 10+)? == (\d+)(?:\.\.\d+)?$/', $gettextAtom, $m)) { |
|
98 | +// f == empty, t == empty, c == empty, e == empty |
|
99 | 99 | return (int) $m[1] === 0 ? true : false; |
100 | 100 | } |
101 | - if (preg_match('/^(?:f|t|c|e)(?: % 10+)? != (\d+)(?:\.\.\d+)?$/', $gettextAtom, $m)) { // f == empty, t == empty, c == empty, e == empty |
|
101 | + if (preg_match('/^(?:f|t|c|e)(?: % 10+)? != (\d+)(?:\.\.\d+)?$/', $gettextAtom, $m)) { |
|
102 | +// f == empty, t == empty, c == empty, e == empty |
|
102 | 103 | return (int) $m[1] === 0 ? false : true; |
103 | 104 | } |
104 | 105 | throw new Exception("Unable to convert the formula chunk '{$cldrAtom}' from CLDR to gettext"); |
@@ -113,8 +114,7 @@ discard block |
||
113 | 114 | * |
114 | 115 | * @return string |
115 | 116 | */ |
116 | - private static function expandAtom($atom) |
|
117 | - { |
|
117 | + private static function expandAtom($atom) { |
|
118 | 118 | $m = null; |
119 | 119 | if (preg_match('/^(n(?: % \d+)?) (==|!=) (\d+(?:\.\.\d+|,\d+)+)$/', $atom, $m)) { |
120 | 120 | $what = $m[1]; |
@@ -5,8 +5,7 @@ |
||
5 | 5 | /** |
6 | 6 | * Interface used by all translators. |
7 | 7 | */ |
8 | -interface TranslatorInterface |
|
9 | -{ |
|
8 | +interface TranslatorInterface { |
|
10 | 9 | /** |
11 | 10 | * Register this translator as global, to use with the gettext functions __(), p__(), etc. |
12 | 11 | * Returns the previous translator if exists. |
@@ -9,8 +9,7 @@ discard block |
||
9 | 9 | * |
10 | 10 | * @return string |
11 | 11 | */ |
12 | -function __($original) |
|
13 | -{ |
|
12 | +function __($original) { |
|
14 | 13 | $text = BaseTranslator::$current->gettext($original); |
15 | 14 | |
16 | 15 | if (func_num_args() === 1) { |
@@ -29,8 +28,7 @@ discard block |
||
29 | 28 | * |
30 | 29 | * @return string |
31 | 30 | */ |
32 | -function noop__($original) |
|
33 | -{ |
|
31 | +function noop__($original) { |
|
34 | 32 | return $original; |
35 | 33 | } |
36 | 34 | |
@@ -43,8 +41,7 @@ discard block |
||
43 | 41 | * |
44 | 42 | * @return string |
45 | 43 | */ |
46 | -function n__($original, $plural, $value) |
|
47 | -{ |
|
44 | +function n__($original, $plural, $value) { |
|
48 | 45 | $text = BaseTranslator::$current->ngettext($original, $plural, $value); |
49 | 46 | |
50 | 47 | if (func_num_args() === 3) { |
@@ -64,8 +61,7 @@ discard block |
||
64 | 61 | * |
65 | 62 | * @return string |
66 | 63 | */ |
67 | -function p__($context, $original) |
|
68 | -{ |
|
64 | +function p__($context, $original) { |
|
69 | 65 | $text = BaseTranslator::$current->pgettext($context, $original); |
70 | 66 | |
71 | 67 | if (func_num_args() === 2) { |
@@ -85,8 +81,7 @@ discard block |
||
85 | 81 | * |
86 | 82 | * @return string |
87 | 83 | */ |
88 | -function d__($domain, $original) |
|
89 | -{ |
|
84 | +function d__($domain, $original) { |
|
90 | 85 | $text = BaseTranslator::$current->dgettext($domain, $original); |
91 | 86 | |
92 | 87 | if (func_num_args() === 2) { |
@@ -107,8 +102,7 @@ discard block |
||
107 | 102 | * |
108 | 103 | * @return string |
109 | 104 | */ |
110 | -function dp__($domain, $context, $original) |
|
111 | -{ |
|
105 | +function dp__($domain, $context, $original) { |
|
112 | 106 | $text = BaseTranslator::$current->dpgettext($domain, $context, $original); |
113 | 107 | |
114 | 108 | if (func_num_args() === 3) { |
@@ -130,8 +124,7 @@ discard block |
||
130 | 124 | * |
131 | 125 | * @return string |
132 | 126 | */ |
133 | -function dn__($domain, $original, $plural, $value) |
|
134 | -{ |
|
127 | +function dn__($domain, $original, $plural, $value) { |
|
135 | 128 | $text = BaseTranslator::$current->dngettext($domain, $original, $plural, $value); |
136 | 129 | |
137 | 130 | if (func_num_args() === 4) { |
@@ -153,8 +146,7 @@ discard block |
||
153 | 146 | * |
154 | 147 | * @return string |
155 | 148 | */ |
156 | -function np__($context, $original, $plural, $value) |
|
157 | -{ |
|
149 | +function np__($context, $original, $plural, $value) { |
|
158 | 150 | $text = BaseTranslator::$current->npgettext($context, $original, $plural, $value); |
159 | 151 | |
160 | 152 | if (func_num_args() === 4) { |
@@ -177,8 +169,7 @@ discard block |
||
177 | 169 | * |
178 | 170 | * @return string |
179 | 171 | */ |
180 | -function dnp__($domain, $context, $original, $plural, $value) |
|
181 | -{ |
|
172 | +function dnp__($domain, $context, $original, $plural, $value) { |
|
182 | 173 | $text = BaseTranslator::$current->dnpgettext($domain, $context, $original, $plural, $value); |
183 | 174 | |
184 | 175 | if (func_num_args() === 5) { |
@@ -5,8 +5,7 @@ discard block |
||
5 | 5 | use Gettext\Translations; |
6 | 6 | use Gettext\Utils\MultidimensionalArrayTrait; |
7 | 7 | |
8 | -class PhpArray extends Generator implements GeneratorInterface |
|
9 | -{ |
|
8 | +class PhpArray extends Generator implements GeneratorInterface { |
|
10 | 9 | use MultidimensionalArrayTrait; |
11 | 10 | |
12 | 11 | public static $options = [ |
@@ -16,8 +15,7 @@ discard block |
||
16 | 15 | /** |
17 | 16 | * {@inheritdoc} |
18 | 17 | */ |
19 | - public static function toString(Translations $translations, array $options = []) |
|
20 | - { |
|
18 | + public static function toString(Translations $translations, array $options = []) { |
|
21 | 19 | $array = static::generate($translations, $options); |
22 | 20 | |
23 | 21 | return '<?php return '.var_export($array, true).';'; |
@@ -31,8 +29,7 @@ discard block |
||
31 | 29 | * |
32 | 30 | * @return array |
33 | 31 | */ |
34 | - public static function generate(Translations $translations, array $options = []) |
|
35 | - { |
|
32 | + public static function generate(Translations $translations, array $options = []) { |
|
36 | 33 | $options += static::$options; |
37 | 34 | |
38 | 35 | return static::toArray($translations, $options['includeHeaders'], true); |
@@ -6,8 +6,7 @@ discard block |
||
6 | 6 | use Gettext\Utils\DictionaryTrait; |
7 | 7 | use Gettext\Utils\CsvTrait; |
8 | 8 | |
9 | -class CsvDictionary extends Generator implements GeneratorInterface |
|
10 | -{ |
|
9 | +class CsvDictionary extends Generator implements GeneratorInterface { |
|
11 | 10 | use DictionaryTrait; |
12 | 11 | use CsvTrait; |
13 | 12 | |
@@ -21,8 +20,7 @@ discard block |
||
21 | 20 | /** |
22 | 21 | * {@parentDoc}. |
23 | 22 | */ |
24 | - public static function toString(Translations $translations, array $options = []) |
|
25 | - { |
|
23 | + public static function toString(Translations $translations, array $options = []) { |
|
26 | 24 | $options += static::$options; |
27 | 25 | $handle = fopen('php://memory', 'w'); |
28 | 26 |
@@ -6,15 +6,13 @@ discard block |
||
6 | 6 | use Gettext\Translations; |
7 | 7 | use DOMDocument; |
8 | 8 | |
9 | -class Xliff extends Generator implements GeneratorInterface |
|
10 | -{ |
|
9 | +class Xliff extends Generator implements GeneratorInterface { |
|
11 | 10 | const UNIT_ID_REGEXP = '/^XLIFF_UNIT_ID: (.*)$/'; |
12 | 11 | |
13 | 12 | /** |
14 | 13 | * {@inheritdoc} |
15 | 14 | */ |
16 | - public static function toString(Translations $translations, array $options = []) |
|
17 | - { |
|
15 | + public static function toString(Translations $translations, array $options = []) { |
|
18 | 16 | $dom = new DOMDocument('1.0', 'utf-8'); |
19 | 17 | $dom->formatOutput = true; |
20 | 18 | $xliff = $dom->appendChild($dom->createElement('xliff')); |
@@ -92,8 +90,7 @@ discard block |
||
92 | 90 | return $dom->saveXML(); |
93 | 91 | } |
94 | 92 | |
95 | - protected static function createTextNode(DOMDocument $dom, $name, $string) |
|
96 | - { |
|
93 | + protected static function createTextNode(DOMDocument $dom, $name, $string) { |
|
97 | 94 | $node = $dom->createElement($name); |
98 | 95 | $text = (preg_match('/[&<>]/', $string) === 1) |
99 | 96 | ? $dom->createCDATASection($string) |
@@ -110,8 +107,7 @@ discard block |
||
110 | 107 | * |
111 | 108 | * @return string|null |
112 | 109 | */ |
113 | - public static function getUnitID(Translation $translation) |
|
114 | - { |
|
110 | + public static function getUnitID(Translation $translation) { |
|
115 | 111 | foreach ($translation->getComments() as $comment) { |
116 | 112 | if (preg_match(static::UNIT_ID_REGEXP, $comment, $matches)) { |
117 | 113 | return $matches[1]; |