Switch some HTMLForms in special pages to OOUI
[lhc/web/wiklou.git] / includes / Message.php
index 134af0e..329d97a 100644 (file)
@@ -364,6 +364,31 @@ class Message implements MessageSpecifier {
                return new self( $keys );
        }
 
+       /**
+        * Get a title object for a mediawiki message, where it can be found in the mediawiki namespace.
+        * The title will be for the current language, if the message key is in
+        * $wgForceUIMsgAsContentMsg it will be append with the language code (except content
+        * language), because Message::inContentLanguage will also return in user language.
+        *
+        * @see $wgForceUIMsgAsContentMsg
+        * @return Title
+        * @since 1.26
+        */
+       public function getTitle() {
+               global $wgContLang, $wgForceUIMsgAsContentMsg;
+
+               $code = $this->language->getCode();
+               $title = $this->key;
+               if (
+                       $wgContLang->getCode() !== $code
+                       && in_array( $this->key, (array)$wgForceUIMsgAsContentMsg )
+               ) {
+                       $title .= '/' . $code;
+               }
+
+               return Title::makeTitle( NS_MEDIAWIKI, $wgContLang->ucfirst( strtr( $title, ' ', '_' ) ) );
+       }
+
        /**
         * Adds parameters to the parameter list of this message.
         *
@@ -597,7 +622,7 @@ class Message implements MessageSpecifier {
                if ( $lang instanceof Language || $lang instanceof StubUserLang ) {
                        $this->language = $lang;
                } elseif ( is_string( $lang ) ) {
-                       if ( $this->language->getCode() != $lang ) {
+                       if ( !$this->language instanceof Language || $this->language->getCode() != $lang ) {
                                $this->language = Language::factory( $lang );
                        }
                } else {