public function getTitle() {
global $wgContLang, $wgForceUIMsgAsContentMsg;
- $code = $this->getLanguage()->getCode();
$title = $this->key;
if (
- $wgContLang->getCode() !== $code
+ !$this->language->equals( $wgContLang )
&& in_array( $this->key, (array)$wgForceUIMsgAsContentMsg )
) {
+ $code = $this->language->getCode();
$title .= '/' . $code;
}
if ( $url === false
&& $wgVariantArticlePath
&& preg_match( '/^variant=([^&]*)$/', $query, $matches )
- && $wgContLang->getCode() === $this->getPageLanguage()->getCode()
+ && $this->getPageLanguage()->equals( $wgContLang )
&& $this->getPageLanguage()->hasVariants()
) {
$variant = urldecode( $matches[1] );
$customiseFilterEnabled = $params['customised'] !== 'all';
if ( $customiseFilterEnabled ) {
global $wgContLang;
- $lang = $langObj->getCode();
$customisedMessages = AllMessagesTablePager::getCustomisedStatuses(
array_map(
[ $langObj, 'ucfirst' ],
$messages_target
),
- $lang,
- $lang != $wgContLang->getCode()
+ $langObj->getCode(),
+ !$langObj->equals( $wgContLang )
);
$customised = $params['customised'] === 'modified';
$user = $context->getUser();
// Check for non-standard user language; this covers uselang,
// and extensions for auto-detecting user language.
- $ulang = $context->getLanguage()->getCode();
- $clang = $wgContLang->getCode();
+ $ulang = $context->getLanguage();
// Check that there are no other sources of variation
- if ( $user->getId() || $user->getNewtalk() || $ulang != $clang ) {
+ if ( $user->getId() || $user->getNewtalk() || $ulang->equals( $wgContLang ) ) {
return false;
}
// Allow extensions to disable caching
}
// Check the object and lazy-loaded options
return (
- $this->mUserLang->getCode() === $other->mUserLang->getCode() &&
+ $this->mUserLang->equals( $other->mUserLang ) &&
$this->getDateFormat() === $other->getDateFormat()
);
}
$this->lang = ( $langObj ? $langObj : $wgContLang );
$this->langcode = $this->lang->getCode();
- $this->foreign = $this->langcode !== $wgContLang->getCode();
+ $this->foreign = !$this->lang->equals( $wgContLang );
$request = $this->getRequest();
return $lang;
}
+ /**
+ * Compare with an other language object
+ *
+ * @since 1.28
+ * @param Language $lang
+ * @return boolean
+ */
+ public function equals( Language $lang ) {
+ return $lang->getCode() === $this->mCode;
+ }
+
/**
* Get the internal language code for this language object
*