Index: trunk/extensions/LiveTranslate/LiveTranslate.php |
— | — | @@ -47,6 +47,7 @@ |
48 | 48 | |
49 | 49 | $wgAutoloadClasses['LiveTranslateHooks'] = $egLiveTranslateIP . '/LiveTranslate.hooks.php'; |
50 | 50 | $wgAutoloadClasses['ApiLiveTranslate'] = $egLiveTranslateIP . '/api/ApiLiveTranslate.php'; |
| 51 | +$wgAutoloadClasses['LiveTranslateFunctions'] = $egLiveTranslateIP . '/includes/LiveTranslateFunctions.php'; |
51 | 52 | |
52 | 53 | $wgAPIModules['livetranslate'] = 'ApiLiveTranslate'; |
53 | 54 | |
— | — | @@ -55,5 +56,23 @@ |
56 | 57 | $wgHooks['ArticleSaveComplete'][] = 'LiveTranslateHooks::onArticleSaveComplete'; |
57 | 58 | $wgHooks['OutputPageBeforeHTML'][] = 'LiveTranslateHooks::onOutputPageBeforeHTML'; |
58 | 59 | |
| 60 | +$egLTJSMessages = array( |
59 | 61 | |
| 62 | +); |
| 63 | + |
| 64 | +// For backward compatibility with MW < 1.17. |
| 65 | +if ( is_callable( array( 'OutputPage', 'addModules' ) ) ) { |
| 66 | + $moduleTemplate = array( |
| 67 | + 'localBasePath' => dirname( __FILE__ ), |
| 68 | + 'remoteBasePath' => $egLiveTranslateScriptPath, |
| 69 | + 'group' => 'ext.livetranslate' |
| 70 | + ); |
| 71 | + |
| 72 | + $wgResourceModules['ext.livetranslate'] = $moduleTemplate + array( |
| 73 | + 'scripts' => 'includes/ext.livetranslate.js', |
| 74 | + 'dependencies' => array(), |
| 75 | + 'messages' => $egLTJSMessages |
| 76 | + ); |
| 77 | +} |
| 78 | + |
60 | 79 | require_once 'LiveTranslate_Settings.php'; |
Index: trunk/extensions/LiveTranslate/includes/ext.livetranslate.js |
— | — | @@ -0,0 +1,28 @@ |
| 2 | +/** |
| 3 | + * JavasSript for the Push tab in the Push extension. |
| 4 | + * @see http://www.mediawiki.org/wiki/Extension:Push |
| 5 | + * |
| 6 | + * @author Jeroen De Dauw <jeroendedauw at gmail dot com> |
| 7 | + */ |
| 8 | + |
| 9 | +(function($) { $( document ).ready( function() { |
| 10 | + |
| 11 | + // Compatibility with pre-RL code. |
| 12 | + // Messages will have been loaded into wgPushMessages. |
| 13 | + if ( typeof mediaWiki === 'undefined' ) { |
| 14 | + mediaWiki = new Object(); |
| 15 | + |
| 16 | + mediaWiki.msg = function() { |
| 17 | + message = window.wgLTEMessages[arguments[0]]; |
| 18 | + |
| 19 | + for ( var i = arguments.length - 1; i > 0; i-- ) { |
| 20 | + message = message.replace( '$' + i, arguments[i] ); |
| 21 | + } |
| 22 | + |
| 23 | + return message; |
| 24 | + } |
| 25 | + } |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | +} ); })(jQuery); |
\ No newline at end of file |
Property changes on: trunk/extensions/LiveTranslate/includes/ext.livetranslate.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 30 | + native |
Index: trunk/extensions/LiveTranslate/includes/LiveTranslate_Functions.php |
— | — | @@ -0,0 +1,33 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Statis class with utility methods for the Live Translate extension. |
| 6 | + * |
| 7 | + * @since 0.1 |
| 8 | + * |
| 9 | + * @file LiveTranslate_Functions.php |
| 10 | + * @ingroup LiveTranslate |
| 11 | + * |
| 12 | + * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
| 13 | + */ |
| 14 | +final class PushFunctions { |
| 15 | + |
| 16 | + /** |
| 17 | + * Adds the needed JS messages to the page output. |
| 18 | + * This is for backward compatibility with pre-RL MediaWiki. |
| 19 | + * |
| 20 | + * @since 0.1 |
| 21 | + */ |
| 22 | + public static function addJSLocalisation() { |
| 23 | + global $egLTJSMessages, $wgOut; |
| 24 | + |
| 25 | + $data = array(); |
| 26 | + |
| 27 | + foreach ( $egLTJSMessages as $msg ) { |
| 28 | + $data[$msg] = wfMsgNoTrans( $msg ); |
| 29 | + } |
| 30 | + |
| 31 | + $wgOut->addInlineScript( 'var wgLTEMessages = ' . json_encode( $data ) . ';' ); |
| 32 | + } |
| 33 | + |
| 34 | +} |
\ No newline at end of file |
Property changes on: trunk/extensions/LiveTranslate/includes/LiveTranslate_Functions.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 35 | + native |