X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=languages%2FLanguage.php;h=86639a3ae774faedf08708ce8e47b3f931c5404e;hb=5098f9f1b17c29904d1f8219016b764e638a38a5;hp=2523814d35f2736ed7ec5b0028a4046bae587141;hpb=6c056478b16f62fc3480035ba69bd94d52bb076a;p=lhc%2Fweb%2Fwiklou.git diff --git a/languages/Language.php b/languages/Language.php index 2523814d35..86639a3ae7 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -49,12 +49,14 @@ class FakeConverter { */ public $mLang; function __construct( $langobj ) { $this->mLang = $langobj; } + function autoConvert( $text, $variant = false ) { return $text; } function autoConvertToAllVariants( $text ) { return array( $this->mLang->getCode() => $text ); } function convert( $t ) { return $t; } function convertTo( $text, $variant ) { return $text; } function convertTitle( $t ) { return $t->getPrefixedText(); } function convertNamespace( $ns ) { return $this->mLang->getFormattedNsText( $ns ); } function getVariants() { return array( $this->mLang->getCode() ); } + function getVariantFallbacks( $variant ) { return $this->mLang->getCode(); } function getPreferredVariant() { return $this->mLang->getCode(); } function getDefaultVariant() { return $this->mLang->getCode(); } function getURLVariant() { return ''; } @@ -66,6 +68,8 @@ class FakeConverter { function convertCategoryKey( $key ) { return $key; } function convertLinkToAllVariants( $text ) { return $this->autoConvertToAllVariants( $text ); } function armourMath( $text ) { return $text; } + function validateVariant( $variant = null ) { return $variant === $this->mLang->getCode() ? $variant : null; } + function translate( $text, $variant ) { return $text; } } /** @@ -682,7 +686,18 @@ class Language { } } - $this->namespaceAliases = $aliases; + # Also add converted namespace names as aliases, to avoid confusion. + $convertedNames = array(); + foreach ( $this->getVariants() as $variant ) { + if ( $variant === $this->mCode ) { + continue; + } + foreach ( $this->getNamespaces() as $ns => $_ ) { + $convertedNames[$this->getConverter()->convertNamespace( $ns, $variant )] = $ns; + } + } + + $this->namespaceAliases = $aliases + $convertedNames; } return $this->namespaceAliases; } @@ -2089,9 +2104,8 @@ class Language { $segments = array(); foreach ( $intervals as $intervalName => $intervalValue ) { - // Give grep a chance to find the usages: - // duration-centuries, duration-decades, duration-years, duration-days, - // duration-hours, duration-minutes, duration-seconds + // Messages: duration-seconds, duration-minutes, duration-hours, duration-days, duration-weeks, + // duration-years, duration-decades, duration-centuries, duration-millennia $message = wfMessage( 'duration-' . $intervalName )->numParams( $intervalValue ); $segments[] = $message->inLanguage( $this )->escaped(); } @@ -3621,7 +3635,7 @@ class Language { foreach ( $forms as $index => $form ) { if ( preg_match( '/^\d+=/i', $form ) ) { $pos = strpos( $form, '=' ); - if ( substr( $form, 0, $pos ) === (string) $count ) { + if ( substr( $form, 0, $pos ) === (string)$count ) { return substr( $form, $pos + 1 ); } unset( $forms[$index] );