Jump to content

Extension talk:Polyglot/Archive 2

About this board

Previous discussion was archived at Extension talk:Polyglot/Archive on 19 May 2020.

Problem with MW 1.35 - language codes prepended to links

4
Choralia (talkcontribs)

When used with MW 1.35 links in the language selector (under "In other languages" in the left sidebar) seem wrong. For example, the link to the main page in French is fr:Main_Page/fr that links to a non-existing page and it does not correctly open Main_Page/fr.

I've been able to fix the problem by patching line 305 in Polyglot.php from:

$fakelinks[] = $lang . ':' . $t;

to:

$fakelinks[] = $t;

however I'm not sure whether it's an appropriate solution or just a workaround.

S.piccardi (talkcontribs)

Don't know if it's just a workaround or not, but at least this gives usable links.

I mediawiki 1.30 the original code worked fine (giving links to the right page, but with the language name instead of the page name) and it was nicer. But this part of the code is identical, so probably something changed in the call to:

        $parser->getOutput()->setLanguageLinks($fakelinks);

Holger Blasum (talkcontribs)

Also on MW 1.35 below is an alternative workaround (which keeps language name as observed by S.piccardi) in form of a modification to Skin.php in patch format (the two replaced lines are noted with '-', and the two lines replacing them are noted with '+'). Note: this works for me, but might break other things, e.g. if you use interwiki links (which I do not use) etc ...

--- original/includes/skins/Skin.php	2022-03-31 21:07:59.044649800 +0000
+++ my.modification/includes/skins/Skin.php	2022-06-16 21:36:54.393564938 +0000
@@ -1363,14 +1363,14 @@ abstract class Skin extends ContextSourc
 		foreach ( $this->getOutput()->getLanguageLinks() as $languageLinkText ) {
 			$class = 'interlanguage-link interwiki-' . explode( ':', $languageLinkText, 2 )[0];
 
-			$languageLinkTitle = Title::newFromText( $languageLinkText );
+			$languageLinkTitle = Title::newFromText( explode(':', $languageLinkText, 2)[1] );
 			if ( !$languageLinkTitle ) {
 				continue;
 			}
 
 			$ilInterwikiCode = $this->mapInterwikiToLanguage( $languageLinkTitle->getInterwiki() );
 
-			$ilLangName = $langNameUtils->getLanguageName( $ilInterwikiCode );
+			$ilLangName = $langNameUtils->getLanguageName( explode(':', $languageLinkText, 2)[0]);
 
 			if ( strval( $ilLangName ) === '' ) {
 				$ilDisplayTextMsg = $this->msg( "interlanguage-link-$ilInterwikiCode" );

Hakaminah (talkcontribs)

Coming to say that the extension works fine with S.piccardi's fix even 3 years after it was posted, though I wish there was an update for MW 1.42+ that brought back all of the extension's functionality.

Checked Holger Blasum's code out of curiosity and it had a funny interaction with custom namespaces. Unfortunately can't recommend without alternations.

Reply to "Problem with MW 1.35 - language codes prepended to links"
There are no older topics