Carlb added a comment.
This is just an untested idea, but perhaps a more general solution would be to str_replace the group name and (in the lone case where $group=='wikipedia') also str_replace out the 'wiki' suffix. Something like: public function getInterwikiCodeFromSite( Site $site ) { $id = $site->getGlobalId(); $group = $site->getGroup(); $id = str_replace($group,'',$id); if ( $group=='wikipedia' ) $id = str_replace( 'wiki', '', $id ); $id = strtr( $id, [ '_' => '-' ] ); if ( !$id ) { $id = $site->getLanguageCode(); } return $id; } That way, the original poster's issue where "wiki" is part of the name of a non-Wikipedia / non-Wikimedia project might be addressed, as it's only looking for the configured $group name on non-Wikipedia wikis. TASK DETAIL https://phabricator.wikimedia.org/T172076 EMAIL PREFERENCES https://phabricator.wikimedia.org/settings/panel/emailpreferences/ To: Carlb Cc: Carlb, Aklapper, Florian, PokestarFan, alaa_wmde, Nandana, Lahi, Gq86, GoranSMilovanovic, QZanden, LawExplorer, _jensen, rosalieper, Wikidata-bugs, aude, Mbch331
_______________________________________________ Wikidata-bugs mailing list Wikidata-bugs@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs