*/
use CLDRPluralRuleParser\Evaluator;
+use MediaWiki\MediaWikiServices;
use Wikimedia\Assert\Assert;
/**
if ( is_null( $this->namespaceNames ) ) {
global $wgMetaNamespace, $wgMetaNamespaceTalk, $wgExtraNamespaces;
- $validNamespaces = MWNamespace::getCanonicalNamespaces();
+ $validNamespaces = MediaWikiServices::getInstance()->getNamespaceInfo()->
+ getCanonicalNamespaces();
$this->namespaceNames = $wgExtraNamespaces +
self::$dataCache->getItem( $this->mCode, 'namespaceNames' );
*/
public function getNsIndex( $text ) {
$lctext = $this->lc( $text );
- $ns = MWNamespace::getCanonicalIndex( $lctext );
+ $ns = MediaWikiServices::getInstance()->getNamespaceInfo()->
+ getCanonicalIndex( $lctext );
if ( $ns !== null ) {
return $ns;
}
$gy_offset = '元';
}
$gy_offset = '昭和' . $gy_offset;
- } else {
+ } elseif (
+ ( ( $gy == 1989 ) && ( $gm == 1 ) && ( $gd >= 8 ) ) ||
+ ( ( $gy > 1989 ) && ( $gy < 2019 ) ) ||
+ ( ( $gy == 2019 ) && ( $gm < 5 ) )
+ ) {
# Heisei period
$gy_gannen = $gy - 1989 + 1;
$gy_offset = $gy_gannen;
$gy_offset = '元';
}
$gy_offset = '平成' . $gy_offset;
+ } else {
+ # Reiwa period
+ $gy_gannen = $gy - 2019 + 1;
+ $gy_offset = $gy_gannen;
+ if ( $gy_gannen == 1 ) {
+ $gy_offset = '元';
+ }
+ $gy_offset = '令和' . $gy_offset;
}
} else {
$gy_offset = $gy;
public function uc( $str, $first = false ) {
if ( $first ) {
if ( $this->isMultibyte( $str ) ) {
- return mb_strtoupper( mb_substr( $str, 0, 1 ) ) . mb_substr( $str, 1 );
+ return $this->mbUpperChar( mb_substr( $str, 0, 1 ) ) . mb_substr( $str, 1 );
} else {
return ucfirst( $str );
}
}
}
+ /**
+ * Convert character to uppercase, allowing overrides of the default mb_upper
+ * behaviour, which is buggy in many ways. Having a conversion table can be
+ * useful during transitions between PHP versions where unicode changes happen.
+ * This can make some resources unreachable on-wiki, see discussion at T219279.
+ * Providing such a conversion table can allow to manage the transition period.
+ *
+ * @since 1.34
+ *
+ * @param string $char
+ *
+ * @return string
+ */
+ protected function mbUpperChar( $char ) {
+ global $wgOverrideUcfirstCharacters;
+ if ( array_key_exists( $char, $wgOverrideUcfirstCharacters ) ) {
+ return $wgOverrideUcfirstCharacters[$char];
+ } else {
+ return mb_strtoupper( $char );
+ }
+ }
+
/**
* @param string $str
* @return mixed|string
}
/**
- * @return array
+ * @return string
*/
function fallback8bitEncoding() {
return self::$dataCache->getItem( $this->mCode, 'fallback8bitEncoding' );
}
}
- /**
- * @deprecated No-op since 1.28
- */
- function initEncoding() {
- wfDeprecated( __METHOD__, '1.28' );
- // No-op.
- }
-
- /**
- * @param string $s
- * @return string
- * @deprecated No-op since 1.28
- */
- function recodeForEdit( $s ) {
- wfDeprecated( __METHOD__, '1.28' );
- return $s;
- }
-
- /**
- * @param string $s
- * @return string
- * @deprecated No-op since 1.28
- */
- function recodeInput( $s ) {
- wfDeprecated( __METHOD__, '1.28' );
- return $s;
- }
-
/**
* Convert a UTF-8 string to normal form C. In Malayalam and Arabic, this
* also cleans up certain backwards-compatible sequences, converting them
return $this->mHtmlCode;
}
- /**
- * @param string $code
- * @deprecated since 1.32, use Language::factory to create a new object instead.
- */
- public function setCode( $code ) {
- wfDeprecated( __METHOD__, '1.32' );
- $this->mCode = $code;
- // Ensure we don't leave incorrect cached data lying around
- $this->mHtmlCode = null;
- $this->mParentLanguage = false;
- }
-
/**
* Get the language code from a file name. Inverse of getFileName()
* @param string $filename $prefix . $languageCode . $suffix