IAlex has uploaded a new change for review.
https://gerrit.wikimedia.org/r/94603
Change subject: New hook 'LocalisationChecksBlacklist' to allow to extend the
localisation checks blacklist
......................................................................
New hook 'LocalisationChecksBlacklist' to allow to extend the localisation
checks blacklist
The point is to allow to use the blacklist of translatewiki.net,
so the format of $checkBlacklist got changed to be compatible with it.
Change-Id: I5eb328c4bdbb0b21962b89acbe12f46ebb4d9d70
---
M docs/hooks.txt
M maintenance/language/checkLanguage.inc
2 files changed, 78 insertions(+), 54 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/03/94603/1
diff --git a/docs/hooks.txt b/docs/hooks.txt
index 700f765..d349351 100644
--- a/docs/hooks.txt
+++ b/docs/hooks.txt
@@ -769,7 +769,7 @@
'CanIPUseHTTPS': Determine whether the client at a given source IP is likely
to be able to access the wiki via HTTPS.
$ip: The IP address in human-readable form
-&$canDo: This reference should be set to false if the client may not be able
+&$canDo: This reference should be set to false if the client may not be able
to use HTTPS
'CanonicalNamespaces': For extensions adding their own namespaces or altering
@@ -1537,6 +1537,11 @@
$cache: The LocalisationCache object
$code: language code
&$alldata: The localisation data from core and extensions
+
+'LocalisationChecksBlacklist': When fetching the blacklist of
+localisation checks.
+&$blacklist: array of checks to blacklist. See the bottom of
+ maintenance/language/checkLanguage.inc for the format of this variable.
'LogEventsListShowLogExtract': Called before the string is added to OutputPage.
Returning false will prevent the string from being added to the OutputPage.
@@ -2381,7 +2386,7 @@
$values: array of variables with watchlist options
'SpecialWatchlistGetNonRevisionTypes': Called when building sql query for
-SpecialWatchlist. Allows extensions to register custom values they have
+SpecialWatchlist. Allows extensions to register custom values they have
inserted to rc_type so they can be returned as part of the watchlist.
&$nonRevisionTypes: array of values in the rc_type field of recentchanges table
diff --git a/maintenance/language/checkLanguage.inc
b/maintenance/language/checkLanguage.inc
index 4b49ada..f068a4a 100644
--- a/maintenance/language/checkLanguage.inc
+++ b/maintenance/language/checkLanguage.inc
@@ -291,6 +291,17 @@
$this->results[$this->code] =
$this->checkLanguage( $this->code );
}
}
+
+ $results = $this->results;
+ foreach( $results as $code => $checks ) {
+ foreach ( $checks as $check => $messages ) {
+ foreach ( $messages as $key => $details ) {
+ if ( $this->isCheckBlacklisted( $check,
$code, $key ) ) {
+ unset(
$this->results[$code][$check][$key] );
+ }
+ }
+ }
+ }
}
/**
@@ -298,9 +309,51 @@
* @return array The list of checks which should not be executed.
*/
protected function getCheckBlacklist() {
+ static $blacklist = null;
+
+ if ( $blacklist !== null ) {
+ return $blacklist;
+ }
+
global $checkBlacklist;
- return $checkBlacklist;
+ $blacklist = $checkBlacklist;
+
+ wfRunHooks( 'LocalisationChecksBlacklist', array( &$blacklist )
);
+
+ return $blacklist;
+ }
+
+ /**
+ * Verify whether a check is blacklisted.
+ *
+ * @param string $check Check name
+ * @param string $code Language code
+ * @param string|bool $message Message name, or False for a whole
language
+ * @return bool Whether the check is blacklisted
+ */
+ protected function isCheckBlacklisted( $check, $code, $message ) {
+ $blacklist = $this->getCheckBlacklist();
+
+ foreach( $blacklist as $item ) {
+ if ( isset( $item['check'] ) && $check !==
$item['check'] ) {
+ continue;
+ }
+
+ if ( isset( $item['code'] ) && !in_array( $code,
$item['code'] ) ) {
+ continue;
+ }
+
+ if ( isset( $item['message'] ) &&
+ ( $message === false || !in_array( $message,
$item['message'] ) )
+ ) {
+ continue;
+ }
+
+ return true;
+ }
+
+ return false;
}
/**
@@ -319,11 +372,8 @@
}
$checkFunctions = $this->getChecks();
- $checkBlacklist = $this->getCheckBlacklist();
foreach ( $this->checks as $check ) {
- if ( isset( $checkBlacklist[$code] ) &&
- in_array( $check, $checkBlacklist[$code] )
- ) {
+ if ( $this->isCheckBlacklisted( $check, $code, false )
) {
$results[$check] = array();
continue;
}
@@ -675,52 +725,21 @@
}
}
-# Blacklist some checks for some languages
+// Blacklist some checks for some languages or some messages
+// Possible keys of the sub arrays are: 'check', 'code' and 'message'.
$checkBlacklist = array(
-#'code' => array( 'check1', 'check2' ... )
- 'az' => array( 'plural' ),
- 'bo' => array( 'plural' ),
- 'cdo' => array( 'plural' ),
- 'dz' => array( 'plural' ),
- 'id' => array( 'plural' ),
- 'fa' => array( 'plural' ),
- 'gan' => array( 'plural' ),
- 'gan-hans' => array( 'plural' ),
- 'gan-hant' => array( 'plural' ),
- 'gn' => array( 'plural' ),
- 'hak' => array( 'plural' ),
- 'hu' => array( 'plural' ),
- 'ja' => array( 'plural' ), // Does not use plural
- 'jv' => array( 'plural' ),
- 'ka' => array( 'plural' ),
- 'kk-arab' => array( 'plural' ),
- 'kk-cyrl' => array( 'plural' ),
- 'kk-latn' => array( 'plural' ),
- 'km' => array( 'plural' ),
- 'kn' => array( 'plural' ),
- 'ko' => array( 'plural' ),
- 'lzh' => array( 'plural' ),
- 'mn' => array( 'plural' ),
- 'ms' => array( 'plural' ),
- 'my' => array( 'plural', 'chars' ), // Uses a lot zwnj
- 'sah' => array( 'plural' ),
- 'sq' => array( 'plural' ),
- 'tet' => array( 'plural' ),
- 'th' => array( 'plural' ),
- 'to' => array( 'plural' ),
- 'tr' => array( 'plural' ),
- 'vi' => array( 'plural' ),
- 'wuu' => array( 'plural' ),
- 'xmf' => array( 'plural' ),
- 'yo' => array( 'plural' ),
- 'yue' => array( 'plural' ),
- 'zh' => array( 'plural' ),
- 'zh-classical' => array( 'plural' ),
- 'zh-cn' => array( 'plural' ),
- 'zh-hans' => array( 'plural' ),
- 'zh-hant' => array( 'plural' ),
- 'zh-hk' => array( 'plural' ),
- 'zh-sg' => array( 'plural' ),
- 'zh-tw' => array( 'plural' ),
- 'zh-yue' => array( 'plural' ),
+ array(
+ 'check' => 'plural',
+ 'code' => array( 'az', 'bo', 'cdo', 'dz', 'id', 'fa', 'gan',
'gan-hans',
+ 'gan-hant', 'gn', 'hak', 'hu', 'ja', 'jv', 'ka',
'kk-arab',
+ 'kk-cyrl', 'kk-latn', 'km', 'kn', 'ko', 'lzh', 'mn',
'ms',
+ 'my', 'sah', 'sq', 'tet', 'th', 'to', 'tr', 'vi',
'wuu', 'xmf',
+ 'yo', 'yue', 'zh', 'zh-classical', 'zh-cn', 'zh-hans',
+ 'zh-hant', 'zh-hk', 'zh-sg', 'zh-tw', 'zh-yue'
+ ),
+ ),
+ array(
+ 'check' => 'chars',
+ 'code' => array( 'my' ),
+ ),
);
--
To view, visit https://gerrit.wikimedia.org/r/94603
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5eb328c4bdbb0b21962b89acbe12f46ebb4d9d70
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: IAlex <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits