Index: trunk/extensions/ParserFunctions/Convert.php |
— | — | @@ -182,6 +182,19 @@ |
183 | 183 | ); |
184 | 184 | } |
185 | 185 | |
| 186 | + # If the Language hasn't been deliberately specified, get it from the wiki's |
| 187 | + # content language, but run it through a configurable map first |
| 188 | + if( $this->language === true ){ |
| 189 | + global $wgContLang, $wgPFUnitLanguageVariants; |
| 190 | + $code = $wgContLang->getCode(); |
| 191 | + if( isset( $wgPFUnitLanguageVariants[$code] ) ){ |
| 192 | + $this->language = Language::factory( $wgPFUnitLanguageVariants[$code] ); |
| 193 | + } else { |
| 194 | + # Ok, actually *do* use $wgContLang |
| 195 | + $this->language = true; |
| 196 | + } |
| 197 | + } |
| 198 | + |
186 | 199 | return $this->processString( $string ); |
187 | 200 | } |
188 | 201 | |
Index: trunk/extensions/ParserFunctions/ParserFunctions.php |
— | — | @@ -34,6 +34,18 @@ |
35 | 35 | */ |
36 | 36 | $wgPFEnableConvert = false; |
37 | 37 | |
| 38 | +/** |
| 39 | + * The language for 'en' is actually 'en-us', which insists on using non-canonical translations |
| 40 | + * of the SI base units ("meter" rather than "metre" and "liter" rather than "litre"). We |
| 41 | + * can avoid contaminatng dialects by internally mapping languages by default; this is |
| 42 | + * configurable so you can remove it if you like, or add other maps if that's useful. |
| 43 | + * Essentially, if your wiki's $wgContLang appears as a key in this array, the value is |
| 44 | + * what is used as the default language for {{#convert}} output. |
| 45 | + */ |
| 46 | +$wgPFUnitLanguageVariants = array( |
| 47 | + 'en' => 'en-gb' |
| 48 | +); |
| 49 | + |
38 | 50 | /** REGISTRATION */ |
39 | 51 | $wgExtensionCredits['parserhook'][] = array( |
40 | 52 | 'path' => __FILE__, |