Nikerabbit added a comment.
The standard is quite clear on the recommended formatting, and also that language codes are case insensitive.
Internally MediaWiki uses lowercase language codes, and unfortunately those are exposed in user visible places such as when used as subpage for mediawiki
Smalyshev added a comment.
Generally, these are two different language codes - one from label, another from site, which is probably takes from wiki configuration, so they are just what the data says. However, we do normalize the language for sitelinks:
$lang =