feat: add langauge converter support

This should allow MW apply langauge conversion to tab title
This commit is contained in:
alistair3149 2023-02-16 14:10:46 -05:00
parent 365777eae3
commit 874738db2a
No known key found for this signature in database
2 changed files with 88 additions and 86 deletions

View file

@ -87,10 +87,11 @@ class Tabber {
// Use array_pad to make sure at least 2 array values are always returned
list( $tabName, $tabBody ) = array_pad( explode( '=', $tab, 2 ), 2, '' );
$tabName = trim( $tabName );
// Use language converter to get variant title and also escape html
$tabName = $parser->getTargetLanguageConverter()->convertHtml( trim( $tabName ) );
$tabBody = $parser->recursiveTagParse( $tabBody, $frame );
$tab = '<article class="tabber__panel" data-title="' . htmlspecialchars( $tabName ) .
$tab = '<article class="tabber__panel" data-title="' . $tabName .
'">' . $tabBody . '</article>';
return $tab;

View file

@ -62,7 +62,8 @@ class TabberParsoid extends ExtensionTagHandler {
// Use array_pad to make sure at least 2 array values are always returned
list( $tabName, $tabBody ) = array_pad( explode( '=', $tab, 2 ), 2, '' );
$tabName = trim( $tabName );
// Use language converter to get variant title and also escape html
$tabName = $parser->getTargetLanguageConverter()->convertHtml( trim( $tabName ) );
$tabBody = $extApi->domToHTML(
$extApi->wikitextToDOM(
$tabBody,
@ -76,7 +77,7 @@ class TabberParsoid extends ExtensionTagHandler {
)
);
$tab = '<article class="tabber__panel" title="' . htmlspecialchars( $tabName ) .
$tab = '<article class="tabber__panel" title="' . $tabName .
'">' . $tabBody . '</article>';
return $tab;