* Change the message 'yourvariant' to a more descriptive one (might be a bit too...
authorRobin Pepermans <robin@users.mediawiki.org>
Sat, 10 Sep 2011 17:12:35 +0000 (17:12 +0000)
committerRobin Pepermans <robin@users.mediawiki.org>
Sat, 10 Sep 2011 17:12:35 +0000 (17:12 +0000)
* 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)

includes/Preferences.php
languages/Language.php
languages/messages/MessagesEn.php
maintenance/language/messageTypes.inc

index c6ed2f4..9f4e5b2 100644 (file)
@@ -276,13 +276,9 @@ class Preferences {
                if ( !$wgDisableLangConversion ) {
                        $variants = $wgContLang->getVariants();
 
-                       $languages = Language::getLanguageNames();
                        foreach ( $variants as $v ) {
                                $v = str_replace( '_', '-', strtolower( $v ) );
-                               if ( array_key_exists( $v, $languages ) ) {
-                                       // If it doesn't have a name, we'll pretend it doesn't exist
-                                       $variantArray[$v] = $languages[$v];
-                               }
+                               $variantArray[$v] = $wgContLang->getVariantname( $v, false );
                        }
 
                        $options = array();
@@ -297,6 +293,7 @@ class Preferences {
                                        'type' => 'select',
                                        'options' => $options,
                                        'section' => 'personal/i18n',
+                                       'help-message' => 'prefs-help-variant',
                                );
                        }
                }
index cf2c308..f728014 100644 (file)
@@ -506,10 +506,20 @@ class Language {
         * short names for language variants used for language conversion links.
         *
         * @param $code String
+        * @param $usemsg Use the "variantname-xyz" message if it exists
         * @return string
         */
-       function getVariantname( $code ) {
-               return $this->getMessageFromDB( "variantname-$code" );
+       function getVariantname( $code, $usemsg = true ) {
+               $msg = "variantname-$code";
+               $codeArray = list( $rootCode ) = explode( '-', $code );
+               if( $usemsg && wfMessage( $msg )->exists() ) {
+                       return $this->getMessageFromDB( $msg );
+               } elseif( $name = self::getLanguageName( $code ) ) {
+                       return $name; # if it's defined as a language name, show that
+               } else {
+                       # otherwise, output the language code
+                       return $code;
+               }
        }
 
        /**
@@ -2504,7 +2514,7 @@ class Language {
         /**
          * Normally we output all numbers in plain en_US style, that is
          * 293,291.235 for twohundredninetythreethousand-twohundredninetyone
-         * point twohundredthirtyfive. However this is not sutable for all
+         * point twohundredthirtyfive. However this is not suitable for all
          * languages, some such as Pakaran want ੨੯੩,੨੯੫.੨੩੫ and others such as
          * Icelandic just want to use commas instead of dots, and dots instead
          * of commas like "293.291,235".
index 18c0f51..e555319 100644 (file)
@@ -1841,7 +1841,8 @@ This cannot be undone.',
 'prefs-registration-date-time'  => '$1', # only translate this message to other languages if you have to change it
 'yourrealname'                  => 'Real name:',
 'yourlanguage'                  => 'Language:',
-'yourvariant'                   => 'Variant:', # only translate this message to other languages if you have to change it
+'yourvariant'                   => 'Content language variant:',
+'prefs-help-variant'                   => 'Your preferred variant or orthography to display the content pages of this wiki in.',
 'yournick'                      => 'New signature:',
 'prefs-help-signature'          => 'Comments on talk pages should be signed with "<nowiki>~~~~</nowiki>" which will be converted into your signature and a timestamp.',
 'badsig'                        => 'Invalid raw signature.
index 602263d..3195a65 100644 (file)
@@ -199,7 +199,6 @@ $wgOptionalMessages = array(
        'userrights-irreversible-marker',
        'tog-nolangconversion',
        'tog-noconvertlink',
-       'yourvariant',
        'variantname-zh-hans',
        'variantname-zh-hant',
        'variantname-zh-cn',