Amire80 has uploaded a new change for review. https://gerrit.wikimedia.org/r/214019
Change subject: Prevent swapping to an invalid target language ...................................................................... Prevent swapping to an invalid target language Pick a language from ULS common languages instead of swapping when the target language is invalid. This addresses the following comment: https://phabricator.wikimedia.org/T96573#1296025 Bug: T96573 Change-Id: I1f3f9fd3637cd6ab198984a743a28a1cc412c61a --- M modules/source/ext.cx.source.selector.js 1 file changed, 13 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation refs/changes/19/214019/1 diff --git a/modules/source/ext.cx.source.selector.js b/modules/source/ext.cx.source.selector.js index ff01210..2e9f566 100644 --- a/modules/source/ext.cx.source.selector.js +++ b/modules/source/ext.cx.source.selector.js @@ -169,12 +169,22 @@ * @param {string} language A language code */ CXSourceSelector.prototype.setSourceLanguage = function ( language ) { - var langProps; + var langProps, currentSource, newTarget; // Don't let the same languages be selected as source and target. - // Instead, do what the user probably means and swap them. + // Instead, do what the user probably means: either swap them if + // it's valid, or pick the first of the common languages in ULS. if ( language === this.getTargetLanguage() ) { - this.setTargetLanguage( this.getSourceLanguage() ); + currentSource = this.getSourceLanguage(); + + if ( CXSourceSelector.prototype.isValidTarget( currentSource ) ) { + this.setTargetLanguage( currentSource ); + } else { + this.setTargetLanguage( + this.$targetLanguage.data( 'uls' ).options.quickList()[ 0 ] + ); + } + } langProps = { -- To view, visit https://gerrit.wikimedia.org/r/214019 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1f3f9fd3637cd6ab198984a743a28a1cc412c61a Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/ContentTranslation Gerrit-Branch: master Gerrit-Owner: Amire80 <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
