ParsoidImageMap: use wfMessage to localize description types

* The previously failing Parsoid test now passes.

Bug: T311523
Depends-On: Id7d9e82ee4ff20a79ba1a5b2433fa29bc5f76e68
Change-Id: I03115b91fd781b72f0bf2c66cb6c18963a772dab
This commit is contained in:
Subramanya Sastry 2023-09-19 16:57:58 -05:00
parent be9aed5e13
commit 66ec96d6b1
2 changed files with 6 additions and 12 deletions

View file

@ -155,13 +155,11 @@ class ParsoidImageMap extends ExtensionTagHandler implements ExtensionModule {
// Handle desc spec // Handle desc spec
$cmd = strtok( $line, " \t" ); $cmd = strtok( $line, " \t" );
if ( $cmd == 'desc' ) { if ( $cmd == 'desc' ) {
$typesText = $descTypesCanonical; $typesText = wfMessage( 'imagemap_desc_types' )->inContentLanguage()->text();
// FIXME: Support this ... if ( $descTypesCanonical != $typesText ) {
// $typesText = wfMessage( 'imagemap_desc_types' )->inContentLanguage()->text(); // i18n desc types exists
// if ( $descTypesCanonical != $typesText ) { $typesText = $descTypesCanonical . ', ' . $typesText;
// // i18n desc types exists }
// $typesText = $descTypesCanonical . ', ' . $typesText;
// }
$types = array_map( 'trim', explode( ',', $typesText ) ); $types = array_map( 'trim', explode( ',', $typesText ) );
$type = trim( strtok( '' ) ?: '' ); $type = trim( strtok( '' ) ?: '' );
$descType = array_search( $type, $types, true ); $descType = array_search( $type, $types, true );

View file

@ -1,5 +1 @@
{ {}
"Non-default localized (French) description type": {
"wt2html": "<p data-parsoid='{\"dsr\":[0,56,0,0]}'><span typeof=\"mw:Extension/imagemap mw:Error\" about=\"#mwt2\" data-parsoid='{\"dsr\":[0,56,10,11]}' data-mw='{\"name\":\"imagemap\",\"attrs\":{},\"body\":{\"extsrc\":\"\\nImage:Foobar.jpg\\ndesc haut-gauche\\n\"},\"errors\":[{\"key\":\"imagemap_invalid_desc\",\"params\":[\"top-right, bottom-right, bottom-left, top-left, none\"]}]}' data-mw-i18n='{\"/\":{\"lang\":\"x-user\",\"key\":\"imagemap_invalid_desc\",\"params\":[\"top-right, bottom-right, bottom-left, top-left, none\"]}}'>imagemap_invalid_desc</span></p>"
}
}