Merge "Show message fallback keys when using &uselang=qqx"
This commit is contained in:
commit
f01fa66527
3 changed files with 32 additions and 2 deletions
|
|
@ -973,6 +973,11 @@ class Message implements MessageSpecifier, Serializable {
|
|||
return '⧼' . htmlspecialchars( $this->key ) . '⧽';
|
||||
}
|
||||
|
||||
# Replace $/ with a list of alternative message keys for &uselang=qqx.
|
||||
if ( strpos( $string, '$/' ) !== false ) {
|
||||
$keylist = implode( ' / ', $this->keysToTry );
|
||||
$string = str_replace( '$/', $keylist, $string );
|
||||
}
|
||||
# Replace $* with a list of parameters for &uselang=qqx.
|
||||
if ( strpos( $string, '$*' ) !== false ) {
|
||||
$paramlist = '';
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* For all translated messages, this returns the name of the message bracketed.
|
||||
* For all translated messages, this returns a special value handled in Message::format()
|
||||
* to display the message key (and fallback keys) and the parameters passed to the message.
|
||||
* This does not affect untranslated messages.
|
||||
*
|
||||
* NOTE: It returns a valid title, because there are some poorly written
|
||||
|
|
@ -36,6 +37,7 @@ class LanguageQqx extends Language {
|
|||
* @return string
|
||||
*/
|
||||
public function getMessage( $key ) {
|
||||
return "($key$*)";
|
||||
// Special values replaced in Message::format()
|
||||
return '($/$*)';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -836,6 +836,29 @@ class MessageTest extends MediaWikiLangTestCase {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Message::format
|
||||
* @covers LanguageQqx
|
||||
*/
|
||||
public function testQqxPlaceholders() {
|
||||
$this->assertSame(
|
||||
wfMessage( 'test' )->inLanguage( 'qqx' )->text(),
|
||||
'(test)'
|
||||
);
|
||||
$this->assertSame(
|
||||
wfMessage( 'test' )->params( 'a', 'b' )->inLanguage( 'qqx' )->text(),
|
||||
'(test: a, b)'
|
||||
);
|
||||
$this->assertSame(
|
||||
wfMessageFallback( 'test', 'other-test' )->inLanguage( 'qqx' )->text(),
|
||||
'(test / other-test)'
|
||||
);
|
||||
$this->assertSame(
|
||||
wfMessageFallback( 'test', 'other-test' )->params( 'a', 'b' )->inLanguage( 'qqx' )->text(),
|
||||
'(test / other-test: a, b)'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Message::inContentLanguage
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in a new issue