Index: trunk/extensions/Translate/groups/FreeCol/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 | |
— | — | @@ -22,39 +22,7 @@ |
23 | 23 | * @param $warnings \array Array where warnings are appended to. |
24 | 24 | */ |
25 | 25 | protected function FreeColVariablesCheck( $messages, $code, &$warnings ) { |
26 | | - foreach ( $messages as $message ) { |
27 | | - $key = $message->key(); |
28 | | - $definition = $message->definition(); |
29 | | - $translation = $message->translation(); |
30 | | - |
31 | | - $varPattern = '%[a-zA-Z_]+%'; |
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 | | - } |
| 26 | + return parent::parameterCheck( $messages, $code, $warnings, '/%[a-zA-Z_]+%/' ); |
59 | 27 | } |
60 | 28 | |
61 | 29 | /** |
Index: trunk/extensions/Translate/groups/Shapado/Checker.php |
— | — | @@ -22,38 +22,6 @@ |
23 | 23 | * @param $warnings \array Array where warnings are appended to. |
24 | 24 | */ |
25 | 25 | protected function ShapadoVariablesCheck( $messages, $code, &$warnings ) { |
26 | | - foreach ( $messages as $message ) { |
27 | | - $key = $message->key(); |
28 | | - $definition = $message->definition(); |
29 | | - $translation = $message->translation(); |
30 | | - |
31 | | - $varPattern = '%{[a-zA-Z_]+}'; |
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 | | - } |
| 26 | + return parent::parameterCheck( $messages, $code, $warnings, '/%{[a-zA-Z_]+}/' ); |
59 | 27 | } |
60 | 28 | } |
Index: trunk/extensions/Translate/groups/MediaWiki/Checker.php |
— | — | @@ -23,42 +23,7 @@ |
24 | 24 | * @param $warnings \array Array where warnings are appended to. |
25 | 25 | */ |
26 | 26 | protected function wikiParameterCheck( $messages, $code, &$warnings ) { |
27 | | - // @todo Gives false positive on (some?) languages for which a |
28 | | - // parameter is completely left out. Example: |
29 | | - // http://translatewiki.net/w/i.php?title=MediaWiki:Configure-ext-ext-dependencies/zh-hant&action=edit |
30 | | - foreach ( $messages as $message ) { |
31 | | - $key = $message->key(); |
32 | | - $definition = $message->definition(); |
33 | | - $translation = $message->translation(); |
34 | | - |
35 | | - $varPattern = '\$[1-9]'; |
36 | | - preg_match_all( "/$varPattern/U", $definition, $defVars ); |
37 | | - preg_match_all( "/$varPattern/U", $translation, $transVars ); |
38 | | - |
39 | | - # Check for missing variables in the translation |
40 | | - $subcheck = 'missing'; |
41 | | - $params = self::compareArrays( $defVars[0], $transVars[0] ); |
42 | | - if ( count( $params ) ) { |
43 | | - $warnings[$key][] = array( |
44 | | - array( 'variable', $subcheck, $key, $code ), |
45 | | - 'translate-checks-parameters', |
46 | | - array( 'PARAMS', $params ), |
47 | | - array( 'COUNT', count( $params ) ), |
48 | | - ); |
49 | | - } |
50 | | - |
51 | | - # Check for unknown variables in the translation |
52 | | - $subcheck = 'unknown'; |
53 | | - $params = self::compareArrays( $transVars[0], $defVars[0] ); |
54 | | - if ( count( $params ) ) { |
55 | | - $warnings[$key][] = array( |
56 | | - array( 'variable', $subcheck, $key, $code ), |
57 | | - 'translate-checks-parameters-unknown', |
58 | | - array( 'PARAMS', $params ), |
59 | | - array( 'COUNT', count( $params ) ), |
60 | | - ); |
61 | | - } |
62 | | - } |
| 27 | + return parent::parameterCheck( $messages, $code, $warnings, '/\$[1-9]/' ); |
63 | 28 | } |
64 | 29 | |
65 | 30 | /** |