http://www.mediawiki.org/wiki/Special:Code/MediaWiki/73285
Revision: 73285
Author: nikerabbit
Date: 2010-09-18 13:46:15 +0000 (Sat, 18 Sep 2010)
Log Message:
-----------
Reducde code duplication and add one more check for FUDforum
Modified Paths:
--------------
trunk/extensions/Translate/groups/FUDforum/Checker.php
trunk/extensions/Translate/groups/FUDforum/FUDforum.yaml
Modified: trunk/extensions/Translate/groups/FUDforum/Checker.php
===================================================================
--- trunk/extensions/Translate/groups/FUDforum/Checker.php 2010-09-18
11:31:34 UTC (rev 73284)
+++ trunk/extensions/Translate/groups/FUDforum/Checker.php 2010-09-18
13:46:15 UTC (rev 73285)
@@ -4,7 +4,7 @@
*
* @file
* @author Niklas Laxström
- * @copyright Copyright © 2009, Niklas Laxström
+ * @copyright Copyright © 2009-2010, Niklas Laxström
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
2.0 or later
*/
@@ -14,56 +14,15 @@
* @ingroup MessageCheckers
*/
class FUDforumMessageChecker extends MessageChecker {
- /**
- * Checks for missing and unknown variables in translations.
- *
- * @param $messages \array Iterable list of TMessage objects.
- * @param $code \string Language code of the translations.
- * @param $warnings \array Array where warnings are appended to.
- */
+
protected function FUDforumVariablesCheck( $messages, $code, &$warnings
) {
- foreach ( $messages as $message ) {
- $key = $message->key();
- $definition = $message->definition();
- $translation = $message->translation();
+ return parent::parameterCheck( $messages, $code, $warnings,
'/\$[1-9]/' );
+ }
- $varPattern = '\$[1-9]';
- preg_match_all( "/$varPattern/U", $definition, $defVars
);
- preg_match_all( "/$varPattern/U", $translation,
$transVars );
-
- # Check for missing variables in the translation
- $subcheck = 'missing';
- $params = self::compareArrays( $defVars[0],
$transVars[0] );
- if ( count( $params ) ) {
- $warnings[$key][] = array(
- array( 'variable', $subcheck, $key,
$code ),
- 'translate-checks-parameters',
- array( 'PARAMS', $params ),
- array( 'COUNT', count( $params ) ),
- );
- }
-
- # Check for unknown variables in the translation
- $subcheck = 'unknown';
- $params = self::compareArrays( $transVars[0],
$defVars[0] );
- if ( count( $params ) ) {
- $warnings[$key][] = array(
- array( 'variable', $subcheck, $key,
$code ),
- 'translate-checks-parameters-unknown',
- array( 'PARAMS', $params ),
- array( 'COUNT', count( $params ) ),
- );
- }
- }
+ protected function FUDforumLongVariablesCheck( $messages, $code,
&$warnings ) {
+ return parent::parameterCheck( $messages, $code, $warnings,
'/{VAR: [^}]+}/' );
}
- /**
- * Checks for incorrect syntax in translations.
- *
- * @param $messages \array Iterable list of TMessage objects.
- * @param $code \string Language code of the translations.
- * @param $warnings \array Array where warnings are appended to.
- */
protected function FUDforumSyntaxCheck( $messages, $code, &$warnings ) {
foreach ( $messages as $message ) {
$key = $message->key();
Modified: trunk/extensions/Translate/groups/FUDforum/FUDforum.yaml
===================================================================
--- trunk/extensions/Translate/groups/FUDforum/FUDforum.yaml 2010-09-18
11:31:34 UTC (rev 73284)
+++ trunk/extensions/Translate/groups/FUDforum/FUDforum.yaml 2010-09-18
13:46:15 UTC (rev 73285)
@@ -18,6 +18,7 @@
checks:
- FUDforumSyntaxCheck
- FUDforumVariablesCheck
+ - FUDforumLongVariablesCheck
- braceBalanceCheck
AUTOLOAD:
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs