Topic on Extension talk:Translate

Accessing to the translated name page by PHP

2
Marcellinjobard (talkcontribs)

I want to display the translated page name in other page.

If I understand translated title is not in page content but available by API with api.php?action=parse&page=Page_Title/fr&prop=displaytitle

But I'll use a hack of DPL3 to find the translated name of a page with PHP. Skins has access to it thanks to Skin.php with `$out->getPageTitle();` but I don't think that extensions like DPL have access to the "output".

So can I access the translated title from another extension?

APatro (WMF) (talkcontribs)

Hello,


One way you could do this in another extension involves using the \MediaWiki\Extension\Translate\PageTranslation\TranslatablePage class in the Translate extension:

use MediaWiki\Extension\Translate\PageTranslation\TranslatablePage;
// Main Page Translate is the title of the translatable page
$tp = TranslatablePage::newFromTitle( \Title::newFromText( 'Main Page Translate' ) );
// fr is the French language code
$tp->getPageDisplayTitle( 'fr' );

Regards,

Abijeet Patro

Reply to "Accessing to the translated name page by PHP"