Index: trunk/extensions/Babel/Babel.class.php |
— | — | @@ -40,17 +40,24 @@ |
41 | 41 | if ( $name === '' ) { |
42 | 42 | continue; |
43 | 43 | } elseif ( $components !== false ) { |
44 | | - // Non-existent page and valid parameter syntax, babel box |
| 44 | + // Valid parameter syntax (with lowercase language code), babel box |
45 | 45 | $content .= self::mGenerateBox( $components['code'], $components['level'] ); |
46 | 46 | $content .= self::mGenerateCategories( $components['code'], $components['level'] ); |
47 | 47 | } elseif ( self::mPageExists( $template ) ) { |
48 | | - // Check for a template |
| 48 | + // Check for an existing template |
49 | 49 | $templateParameters[0] = $template; |
50 | 50 | $template = implode( '|', $templateParameters ); |
51 | 51 | $content .= self::mGenerateNotaBox( $parser->replaceVariables( "{{{$template}}}" ) ); |
52 | 52 | } elseif ( self::mValidTitle( $template ) ) { |
53 | | - // Non-existent page and invalid parameter syntax, red link. |
54 | | - $content .= self::mGenerateNotaBox( '[[' . $template . ']]' ); |
| 53 | + // Non-existing page, so try again as a babel box, with converting the code to lowercase |
| 54 | + $components2 = self::mParseParameter( $name, /* code to lowercase */ true ); |
| 55 | + if ( $components2 !== false ) { |
| 56 | + $content .= self::mGenerateBox( $components2['code'], $components2['level'] ); |
| 57 | + $content .= self::mGenerateCategories( $components2['code'], $components2['level'] ); |
| 58 | + } else { |
| 59 | + // Non-existent page and invalid parameter syntax, red link. |
| 60 | + $content .= self::mGenerateNotaBox( '[[' . $template . ']]' ); |
| 61 | + } |
55 | 62 | } else { |
56 | 63 | // Invalid title, output raw. |
57 | 64 | $content .= self::mGenerateNotaBox( $template ); |
— | — | @@ -146,13 +153,14 @@ |
147 | 154 | * Parse a parameter, getting a language code and level. |
148 | 155 | * |
149 | 156 | * @param $parameter String: Parameter. |
| 157 | + * @param $strtolower Boolean: Whether to convert the language code to lowercase |
150 | 158 | * @return Array: { 'code' => xx, 'level' => xx } |
151 | 159 | */ |
152 | | - protected static function mParseParameter( $parameter ) { |
| 160 | + protected static function mParseParameter( $parameter, $strtolower = false ) { |
153 | 161 | global $wgBabelDefaultLevel, $wgBabelCategoryNames; |
154 | 162 | $return = array(); |
155 | 163 | |
156 | | - $babelcode = strtolower( $parameter ); |
| 164 | + $babelcode = $strtolower ? strtolower( $parameter ) : $parameter; |
157 | 165 | // Try treating the paramter as a language code (for default level). |
158 | 166 | $code = BabelLanguageCodes::getCode( $babelcode ); |
159 | 167 | if ( $code !== false ) { |
— | — | @@ -168,7 +176,7 @@ |
169 | 177 | $code = substr( $parameter, 0, $lastSplit ); |
170 | 178 | $level = substr( $parameter, $lastSplit + 1 ); |
171 | 179 | |
172 | | - $babelcode = strtolower( $code ); |
| 180 | + $babelcode = $strtolower ? strtolower( $code ) : $code; |
173 | 181 | // Validate code. |
174 | 182 | $return['code'] = BabelLanguageCodes::getCode( $babelcode ); |
175 | 183 | if ( $return['code'] === false ) { |