Normalize message name in Allmessages
* Normalize the message name returned by allmessages * Separate message key normalization into MessageCache::normalizeKey() Bug: T63894 Change-Id: I1d89fc73fea705243d390bab91255a635d8f9eee
This commit is contained in:
parent
958b8f1494
commit
47e0f0c34d
2 changed files with 23 additions and 7 deletions
|
|
@ -136,7 +136,11 @@ class ApiQueryAllMessages extends ApiQueryBase {
|
|||
}
|
||||
|
||||
if ( !$skip ) {
|
||||
$a = array( 'name' => $message );
|
||||
$a = array(
|
||||
'name' => $message,
|
||||
'normalizedname' => MessageCache::normalizeKey( $message ),
|
||||
);
|
||||
|
||||
$args = array();
|
||||
if ( isset( $params['args'] ) && count( $params['args'] ) != 0 ) {
|
||||
$args = $params['args'];
|
||||
|
|
|
|||
24
includes/cache/MessageCache.php
vendored
24
includes/cache/MessageCache.php
vendored
|
|
@ -130,6 +130,23 @@ class MessageCache {
|
|||
self::$instance = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize message key input
|
||||
*
|
||||
* @param string $key Input message key to be normalized
|
||||
* @return string Normalized message key
|
||||
*/
|
||||
public static function normalizeKey( $key ) {
|
||||
$lckey = strtr( $key, ' ', '_' );
|
||||
if ( ord( $lckey ) < 128 ) {
|
||||
$lckey[0] = strtolower( $lckey[0] );
|
||||
} else {
|
||||
$lckey = $wgContLang->lcfirst( $lckey );
|
||||
}
|
||||
|
||||
return $lckey;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BagOStuff $memCached A cache instance. If none, fall back to CACHE_NONE.
|
||||
* @param bool $useDB
|
||||
|
|
@ -784,12 +801,7 @@ class MessageCache {
|
|||
}
|
||||
|
||||
// Normalise title-case input (with some inlining)
|
||||
$lckey = strtr( $key, ' ', '_' );
|
||||
if ( ord( $lckey ) < 128 ) {
|
||||
$lckey[0] = strtolower( $lckey[0] );
|
||||
} else {
|
||||
$lckey = $wgContLang->lcfirst( $lckey );
|
||||
}
|
||||
$lckey = MessageCache::normalizeKey( $key );
|
||||
|
||||
Hooks::run( 'MessageCache::get', array( &$lckey ) );
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue