Index: trunk/extensions/Translate/groups/FUDforum/FUDforum.yaml |
— | — | @@ -18,6 +18,7 @@ |
19 | 19 | checks: |
20 | 20 | - FUDforumSyntaxCheck |
21 | 21 | - FUDforumVariablesCheck |
| 22 | + - FUDforumLongVariablesCheck |
22 | 23 | - braceBalanceCheck |
23 | 24 | |
24 | 25 | AUTOLOAD: |
Index: trunk/extensions/Translate/groups/FUDforum/Checker.php |
— | — | @@ -4,7 +4,7 @@ |
5 | 5 | * |
6 | 6 | * @file |
7 | 7 | * @author Niklas Laxström |
8 | | - * @copyright Copyright © 2009, Niklas Laxström |
| 8 | + * @copyright Copyright © 2009-2010, Niklas Laxström |
9 | 9 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
10 | 10 | */ |
11 | 11 | |
— | — | @@ -14,56 +14,15 @@ |
15 | 15 | * @ingroup MessageCheckers |
16 | 16 | */ |
17 | 17 | class FUDforumMessageChecker extends MessageChecker { |
18 | | - /** |
19 | | - * Checks for missing and unknown variables in translations. |
20 | | - * |
21 | | - * @param $messages \array Iterable list of TMessage objects. |
22 | | - * @param $code \string Language code of the translations. |
23 | | - * @param $warnings \array Array where warnings are appended to. |
24 | | - */ |
| 18 | + |
25 | 19 | protected function FUDforumVariablesCheck( $messages, $code, &$warnings ) { |
26 | | - foreach ( $messages as $message ) { |
27 | | - $key = $message->key(); |
28 | | - $definition = $message->definition(); |
29 | | - $translation = $message->translation(); |
| 20 | + return parent::parameterCheck( $messages, $code, $warnings, '/\$[1-9]/' ); |
| 21 | + } |
30 | 22 | |
31 | | - $varPattern = '\$[1-9]'; |
32 | | - preg_match_all( "/$varPattern/U", $definition, $defVars ); |
33 | | - preg_match_all( "/$varPattern/U", $translation, $transVars ); |
34 | | - |
35 | | - # Check for missing variables in the translation |
36 | | - $subcheck = 'missing'; |
37 | | - $params = self::compareArrays( $defVars[0], $transVars[0] ); |
38 | | - if ( count( $params ) ) { |
39 | | - $warnings[$key][] = array( |
40 | | - array( 'variable', $subcheck, $key, $code ), |
41 | | - 'translate-checks-parameters', |
42 | | - array( 'PARAMS', $params ), |
43 | | - array( 'COUNT', count( $params ) ), |
44 | | - ); |
45 | | - } |
46 | | - |
47 | | - # Check for unknown variables in the translation |
48 | | - $subcheck = 'unknown'; |
49 | | - $params = self::compareArrays( $transVars[0], $defVars[0] ); |
50 | | - if ( count( $params ) ) { |
51 | | - $warnings[$key][] = array( |
52 | | - array( 'variable', $subcheck, $key, $code ), |
53 | | - 'translate-checks-parameters-unknown', |
54 | | - array( 'PARAMS', $params ), |
55 | | - array( 'COUNT', count( $params ) ), |
56 | | - ); |
57 | | - } |
58 | | - } |
| 23 | + protected function FUDforumLongVariablesCheck( $messages, $code, &$warnings ) { |
| 24 | + return parent::parameterCheck( $messages, $code, $warnings, '/{VAR: [^}]+}/' ); |
59 | 25 | } |
60 | 26 | |
61 | | - /** |
62 | | - * Checks for incorrect syntax in translations. |
63 | | - * |
64 | | - * @param $messages \array Iterable list of TMessage objects. |
65 | | - * @param $code \string Language code of the translations. |
66 | | - * @param $warnings \array Array where warnings are appended to. |
67 | | - */ |
68 | 27 | protected function FUDforumSyntaxCheck( $messages, $code, &$warnings ) { |
69 | 28 | foreach ( $messages as $message ) { |
70 | 29 | $key = $message->key(); |