Santhosh has submitted this change and it was merged.
Change subject: PageTranslation with ULS
......................................................................
PageTranslation with ULS
Possibility for ULS to also control content language
Change-Id: I05948032c637abc777e4ccc29aca909ee3ac77a2
---
M Translate.php
A resources/js/ext.translate.pagetranslation.uls.js
M tag/PageTranslationHooks.php
3 files changed, 39 insertions(+), 2 deletions(-)
Approvals:
Santhosh: Verified; Looks good to me, approved
diff --git a/Translate.php b/Translate.php
index ebc809a..be1fafd 100644
--- a/Translate.php
+++ b/Translate.php
@@ -489,6 +489,14 @@
),
) + $resourcePaths;
+$wgResourceModules['ext.translate.pagetranslation.uls'] = array(
+ 'scripts' => 'resources/js/ext.translate.pagetranslation.uls.js',
+ 'dependencies' => array(
+ 'ext.uls.init',
+ 'mediawiki.util',
+ ),
+) + $resourcePaths;
+
$wgResourceModules['jquery.autoresize'] = array(
'scripts' => 'resources/js/jquery.autoresize.js',
) + $resourcePaths;
@@ -654,6 +662,13 @@
*/
$wgPageTranslationNamespace = 1198;
+/**
+ * When user changes interface language via ULS, should we also switch the
+ * language of the translatable page.
+ * @since 2013-03-10
+ */
+$wgTranslatePageTranslationULS = false;
+
# </source>
# === Message group configuration ===
# <source lang=php>
diff --git a/resources/js/ext.translate.pagetranslation.uls.js
b/resources/js/ext.translate.pagetranslation.uls.js
new file mode 100644
index 0000000..d3f4c81
--- /dev/null
+++ b/resources/js/ext.translate.pagetranslation.uls.js
@@ -0,0 +1,14 @@
+( function ( mw ) {
+ 'use strict';
+
+ mw.uls.changeLanguage = function ( language ) {
+ var page, uri;
+ page = 'Special:MyLanguage/' + mw.config.get( 'wgPageName' );
+ uri = new mw.Uri( mw.util.wikiGetlink( page ) );
+
+ uri.extend( {
+ setlang: language
+ } );
+ window.location.href = uri.toString();
+ };
+} ( mediaWiki ) );
diff --git a/tag/PageTranslationHooks.php b/tag/PageTranslationHooks.php
index 283d57f..9fbf597 100644
--- a/tag/PageTranslationHooks.php
+++ b/tag/PageTranslationHooks.php
@@ -68,8 +68,16 @@
}
/// Hook: OutputPageBeforeHTML
- public static function injectCss( OutputPage $outputpage, /*string*/
$text ) {
- $outputpage->addModules( 'ext.translate' );
+ public static function injectCss( OutputPage $out, /*string*/ $text ) {
+ global $wgTranslatePageTranslationULS;
+
+ $title = $out->getTitle();
+ if ( TranslatablePage::isSourcePage( $title ) ||
TranslatablePage::isTranslationPage( $title ) ) {
+ $out->addModules( 'ext.translate' );
+ if ( $wgTranslatePageTranslationULS ) {
+ $out->addModules(
'ext.translate.pagetranslation.uls' );
+ }
+ }
return true;
}
--
To view, visit https://gerrit.wikimedia.org/r/53037
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I05948032c637abc777e4ccc29aca909ee3ac77a2
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Translate
Gerrit-Branch: master
Gerrit-Owner: Nikerabbit <[email protected]>
Gerrit-Reviewer: Santhosh <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits