Remove URL parameter setlang from history when language is unchanged
This change allows to use the ULS language changer without getting a dialog for restoring the old language. This change requires that the module is also loaded in this case. Change-Id: Ie5169e986d0362034ede122b0bc29ce7a4aa481e
This commit is contained in:
@@ -162,11 +162,6 @@ class UniversalLanguageSelectorHooks {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $out->getLanguage()->getCode() === $languageToSet ) {
|
|
||||||
// If we are already using the preferred language, don't bother.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$out->addModules( 'ext.uls.setlang' );
|
$out->addModules( 'ext.uls.setlang' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,6 +51,11 @@
|
|||||||
return uri.toString();
|
return uri.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function removeSetlangFromHistory() {
|
||||||
|
var urlWithoutSetlang = removeParam( 'setlang' );
|
||||||
|
history.replaceState( null, 'no-setlang-url', urlWithoutSetlang );
|
||||||
|
}
|
||||||
|
|
||||||
function updateLanguage( langCode ) {
|
function updateLanguage( langCode ) {
|
||||||
var api = new mw.Api();
|
var api = new mw.Api();
|
||||||
return api.postWithToken( 'csrf', {
|
return api.postWithToken( 'csrf', {
|
||||||
@@ -93,8 +98,7 @@
|
|||||||
} );
|
} );
|
||||||
|
|
||||||
$cancelBtn.on( 'click', function () {
|
$cancelBtn.on( 'click', function () {
|
||||||
var urlWithoutSetlang = removeParam( 'setlang' );
|
removeSetlangFromHistory();
|
||||||
history.replaceState( null, 'no-setlang-url', urlWithoutSetlang );
|
|
||||||
ulsDialog.close();
|
ulsDialog.close();
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
@@ -106,6 +110,7 @@
|
|||||||
$ulsDialog, ulsSetLangDialog;
|
$ulsDialog, ulsSetLangDialog;
|
||||||
|
|
||||||
if ( currentLangCode === setLangCode ) {
|
if ( currentLangCode === setLangCode ) {
|
||||||
|
removeSetlangFromHistory();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user