r52922 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r52921‎ | r52922 | r52923 >
Date:16:33, 8 July 2009
Author:avar
Status:deferred
Tags:
Comment:
Pass $wgLang->getCode() to OpenLayers.Lang.setCode()

Hopefully we'll always have a 1-1 mapping between MediaWiki language
codes and the OpenLayers ones, they're using RFC 3066 to pick names
for their codes:

It's also fine to pass our language code to OpenLayers without any
checking as to whether OL actually supports it, it'll fall back on
OpenLayers.String.defaultLang if it doesn't know what it is, see:

http://dev.openlayers.org/apidocs/files/OpenLayers/Lang-js.html#OpenLayers.Lang.setCode
Modified paths:
  • /trunk/extensions/SlippyMap/SlippyMap.hooks.php (modified) (history)
  • /trunk/extensions/SlippyMap/SlippyMap.js (modified) (history)

Diff [purge]

Index: trunk/extensions/SlippyMap/SlippyMap.hooks.php
@@ -36,7 +36,7 @@
3737 */
3838
3939 public static function onParserFirstCallInit( ) {
40 - global $wgArticle, $wgOut, $wgParser, $wgScriptPath, $wgJsMimeType, $wgStyleVersion, $wgAutoLoadMaps;
 40+ global $wgArticle, $wgOut, $wgLang, $wgParser, $wgScriptPath, $wgJsMimeType, $wgStyleVersion, $wgAutoLoadMaps;
4141
4242 $smh = new SlippyMapHooks();
4343
@@ -62,6 +62,7 @@
6363 "var wgSlippyMapCode = " . Xml::encodeJsVar( wfMsg( 'slippymap_code' ) ) . ";",
6464 "var wgSlippyMapButtonCode = " . Xml::encodeJsVar( wfMsg( 'slippymap_button_code' ) ) . ";",
6565 "var wgSlippyMapResetview = " . Xml::encodeJsVar( wfMsg( 'slippymap_resetview' ) ) . ";",
 66+ "var wgSlippyMapLanguageCode = " . Xml::encodeJsVar( $wgLang->getCode() ) . ";",
6667 "var autoInitMaps = {$autoload};",
6768 "/*]]>*/</script>",
6869 );
Index: trunk/extensions/SlippyMap/SlippyMap.js
@@ -40,6 +40,8 @@
4141 *
4242 */
4343
 44+OpenLayers.Lang.setCode(wgSlippyMapLanguageCode);
 45+
4446 var slippymaps = new Array();
4547 var mapId = 0;
4648 var layer = null;

Status & tagging log