Currently, we (ab)use the content language field from the Site object as the prefix for creating language links. This only works because the content language field does not really contain the actual content language at the moment, see T137537: Ensure correct information about Wikimedia sites in the Sites facility on the Wikimedia cluster..
We should be using the Site's "interwiki" id as the prefix instead. However, this would currently break on the Wikimedia cluster, since non-wikipedia sites have incorrect information for the "interwiki" IDs in the sites table, again see T137537: Ensure correct information about Wikimedia sites in the Sites facility on the Wikimedia cluster..
Relevant code: LangLinkHandler::getInterwikiCodeFromSite
What is now
public function getInterwikiCodeFromSite( Site $site ) { return $site->getLanguageCode(); }
Should become more like:
public function getInterwikiCodeFromSite( Site $site ) { $ids = $site->getInterwikiIds(); return reset( $ids ); }