X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2FMessage.php;h=329d97afac1f9b1e266c7f35e4b4630e6680f187;hb=3a1104b374d209ffa627b48dd2f3a26d0af859ab;hp=134af0ed45c5d120bfb56a96c975260e4bb0f8d6;hpb=3bdc9d715f696c1aee226e3993466adde14cdead;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Message.php b/includes/Message.php index 134af0ed45..329d97afac 100644 --- a/includes/Message.php +++ b/includes/Message.php @@ -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 {