r96723 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96722‎ | r96723 | r96724 >
Date:17:12, 10 September 2011
Author:robin
Status:ok
Tags:
Comment:
* Change the message 'yourvariant' to a more descriptive one (might be a bit too long however), and remove it as an optional message. Also added a help message to explain it.
* Make getVariantname fallback to the language name, and use that in Preferences. Shouldn't change the names in practice, but is a more logical implementation imho.
* (Fix a typo in Language.php)
Modified paths:
  • /trunk/phase3/includes/Preferences.php (modified) (history)
  • /trunk/phase3/languages/Language.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/maintenance/language/messageTypes.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/language/messageTypes.inc
@@ -199,7 +199,6 @@
200200 'userrights-irreversible-marker',
201201 'tog-nolangconversion',
202202 'tog-noconvertlink',
203 - 'yourvariant',
204203 'variantname-zh-hans',
205204 'variantname-zh-hant',
206205 'variantname-zh-cn',
Index: trunk/phase3/includes/Preferences.php
@@ -276,13 +276,9 @@
277277 if ( !$wgDisableLangConversion ) {
278278 $variants = $wgContLang->getVariants();
279279
280 - $languages = Language::getLanguageNames();
281280 foreach ( $variants as $v ) {
282281 $v = str_replace( '_', '-', strtolower( $v ) );
283 - if ( array_key_exists( $v, $languages ) ) {
284 - // If it doesn't have a name, we'll pretend it doesn't exist
285 - $variantArray[$v] = $languages[$v];
286 - }
 282+ $variantArray[$v] = $wgContLang->getVariantname( $v, false );
287283 }
288284
289285 $options = array();
@@ -297,6 +293,7 @@
298294 'type' => 'select',
299295 'options' => $options,
300296 'section' => 'personal/i18n',
 297+ 'help-message' => 'prefs-help-variant',
301298 );
302299 }
303300 }
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -1841,7 +1841,8 @@
18421842 'prefs-registration-date-time' => '$1', # only translate this message to other languages if you have to change it
18431843 'yourrealname' => 'Real name:',
18441844 'yourlanguage' => 'Language:',
1845 -'yourvariant' => 'Variant:', # only translate this message to other languages if you have to change it
 1845+'yourvariant' => 'Content language variant:',
 1846+'prefs-help-variant' => 'Your preferred variant or orthography to display the content pages of this wiki in.',
18461847 'yournick' => 'New signature:',
18471848 'prefs-help-signature' => 'Comments on talk pages should be signed with "<nowiki>~~~~</nowiki>" which will be converted into your signature and a timestamp.',
18481849 'badsig' => 'Invalid raw signature.
Index: trunk/phase3/languages/Language.php
@@ -506,10 +506,20 @@
507507 * short names for language variants used for language conversion links.
508508 *
509509 * @param $code String
 510+ * @param $usemsg Use the "variantname-xyz" message if it exists
510511 * @return string
511512 */
512 - function getVariantname( $code ) {
513 - return $this->getMessageFromDB( "variantname-$code" );
 513+ function getVariantname( $code, $usemsg = true ) {
 514+ $msg = "variantname-$code";
 515+ $codeArray = list( $rootCode ) = explode( '-', $code );
 516+ if( $usemsg && wfMessage( $msg )->exists() ) {
 517+ return $this->getMessageFromDB( $msg );
 518+ } elseif( $name = self::getLanguageName( $code ) ) {
 519+ return $name; # if it's defined as a language name, show that
 520+ } else {
 521+ # otherwise, output the language code
 522+ return $code;
 523+ }
514524 }
515525
516526 /**
@@ -2504,7 +2514,7 @@
25052515 /**
25062516 * Normally we output all numbers in plain en_US style, that is
25072517 * 293,291.235 for twohundredninetythreethousand-twohundredninetyone
2508 - * point twohundredthirtyfive. However this is not sutable for all
 2518+ * point twohundredthirtyfive. However this is not suitable for all
25092519 * languages, some such as Pakaran want ੨੯੩,੨੯੫.੨੩੫ and others such as
25102520 * Icelandic just want to use commas instead of dots, and dots instead
25112521 * of commas like "293.291,235".

Follow-up revisions

RevisionCommit summaryAuthorDate
r96737Correctly parse interface messages as such, so it doesn't get converted accor...robin20:05, 10 September 2011
r96805Per r96723: register new message key to maintenance scriptraymond19:46, 11 September 2011

Status & tagging log