jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/392745 )
Change subject: Have inputbox langconvert certain attributes ...................................................................... Have inputbox langconvert certain attributes This approximates the behaviour prior to core change for T119158. It will language convert the options: default, buttonlabel, searchbuttonlabel, and placeholder if they contain a "-{". The old behaviour was to handle the insides of -{ glossary rules here }- and convert text if there was a glossary rule both prior to the beginning of the attribute and prior to the end of the attribute (So default=foo-{}-bar-{}-baz only bar would be converted). I believe that just looking for -{ is probably close enough. It also opens the question of if these options should always be language converted, but I'll leave that for someone else to decide. Bug: T180485 Change-Id: I3aa10890950afce445075e895baf6b10327bc222 (cherry picked from commit b9e0005c715cbb668af530736b3e3728fe96d77e) --- M InputBox.classes.php M tests/inputBoxParserTests.txt 2 files changed, 52 insertions(+), 1 deletion(-) Approvals: MaxSem: Looks good to me, approved jenkins-bot: Verified diff --git a/InputBox.classes.php b/InputBox.classes.php index f504468..d65a7ac 100644 --- a/InputBox.classes.php +++ b/InputBox.classes.php @@ -641,9 +641,19 @@ 'searchfilter' => 'mSearchFilter', 'tour' => 'mTour' ]; + // Options we should maybe run through lang converter. + $convertOptions = [ + 'default' => true, + 'buttonlabel' => true, + 'searchbuttonlabel' => true, + 'placeholder' => true + ]; foreach ( $options as $name => $var ) { if ( isset( $values[$name] ) ) { $this->$var = $values[$name]; + if ( isset( $convertOptions[$name] ) ) { + $this->$var = $this->languageConvert( $this->$var ); + } } } @@ -695,4 +705,26 @@ private function shouldUseVE() { return ExtensionRegistry::getInstance()->isLoaded( 'VisualEditor' ) && $this->mUseVE !== null; } + + /** + * For compatability with pre T119158 behaviour + * + * If a field that is going to be used as an attribute + * and it contains "-{" in it, run it through language + * converter. + * + * Its not really clear if it would make more sense to + * always convert instead of only if -{ is present. This + * function just more or less restores the previous + * accidental behaviour. + * + * @see https://phabricator.wikimedia.org/T180485 + */ + private function languageConvert( $text ) { + $lang = $this->mParser->getConverterLanguage(); + if ( $lang->hasVariants() && strpos( $text, '-{' ) !== false ) { + $text = $lang->convert( $text ); + } + return $text; + } } diff --git a/tests/inputBoxParserTests.txt b/tests/inputBoxParserTests.txt index 63e0d62..cd629dd 100644 --- a/tests/inputBoxParserTests.txt +++ b/tests/inputBoxParserTests.txt @@ -328,4 +328,23 @@ <input type="submit" name="go" class="mw-ui-button" value="Try exact match" /> <input type="submit" name="fulltext" class="mw-ui-button" value="Search full text" /></p> </form> </div> -!! end \ No newline at end of file +!! end + +!! test +InputBox langconvert +!! options +language=sr variant=sr-el +!! wikitext +<inputbox> +type=create +default=-{sr-el: Some latin; sr-ec: Not latin }- +placeholder=-{sr-el: el; sr-ec: ec}- +</inputbox> +!! html+tidy +<div class="mw-inputbox-centered" style=""> +<form name="createbox" class="createbox" action="/index.php" method="get" id="createbox"> +<p><input type="hidden" value="edit" name="action" /><input type="text" name="title" class="mw-inputbox-input mw-ui-input mw-ui-input-inline createboxInput" value="Some latin" placeholder="el" size="50" dir="ltr" /><br /> +<input type="submit" name="create" class="mw-ui-button mw-ui-progressive createboxButton" value="Направи страницу" /></p> +</form> +</div> +!! end -- To view, visit https://gerrit.wikimedia.org/r/392745 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I3aa10890950afce445075e895baf6b10327bc222 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/InputBox Gerrit-Branch: wmf/1.31.0-wmf.8 Gerrit-Owner: Brian Wolff <bawolff...@gmail.com> Gerrit-Reviewer: Jackmcbarn <jackmcb...@gmail.com> Gerrit-Reviewer: MaxSem <maxsem.w...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits