- $variants = $lang->getVariants();
- $aloption = [];
- foreach ( $variants as $variant ) {
- if ( $variant === $lang->getCode() ) {
- continue;
- }
-
- // XXX Note that this code is not strictly correct: we
- // do a case-insensitive match in
- // LanguageConverter::getHeaderVariant() while the
- // (abandoned, draft) spec for the `Key` header only
- // allows case-sensitive matches. To match the logic
- // in LanguageConverter::getHeaderVariant() we should
- // also be looking at fallback variants and deprecated
- // mediawiki-internal codes, as well as BCP 47
- // normalized forms.
-
- $aloption[] = "substr=$variant";
-
- // IE and some other browsers use BCP 47 standards in their Accept-Language header,
- // like "zh-CN" or "zh-Hant". We should handle these too.
- $variantBCP47 = LanguageCode::bcp47( $variant );
- if ( $variantBCP47 !== $variant ) {
- $aloption[] = "substr=$variantBCP47";
- }
- }
- $this->addVaryHeader( 'Accept-Language', $aloption );