From: Matthias Mullie Date: Tue, 6 Mar 2018 17:32:31 +0000 (+0100) Subject: Fall back to default language when no i18n'ed licenses available X-Git-Tag: 1.34.0-rc.0~5495^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22auteur_infos%22%2C%20%22id_auteur=%24id%22%29%20.%20%22?a=commitdiff_plain;h=76c888bbc542e65f69554b248cd0959a4402513d;p=lhc%2Fweb%2Fwiklou.git Fall back to default language when no i18n'ed licenses available Bug: T188822 Change-Id: I5de0167b343c2ce3752f54d2b4418a27aad819c0 --- diff --git a/includes/specials/formfields/Licenses.php b/includes/specials/formfields/Licenses.php index 931cd240a0..a2f3128462 100644 --- a/includes/specials/formfields/Licenses.php +++ b/includes/specials/formfields/Licenses.php @@ -57,9 +57,25 @@ class Licenses extends HTMLFormField { * @return string */ protected static function getMessageFromParams( $params ) { - return empty( $params['licenses'] ) - ? wfMessage( 'licenses' )->inContentLanguage()->plain() - : $params['licenses']; + global $wgContLang; + + if ( !empty( $params['licenses'] ) ) { + return $params['licenses']; + } + + // If the licenses page is in $wgForceUIMsgAsContentMsg (which is the case + // on Commons), translations will be in the database, in subpages of this + // message (e.g. MediaWiki:Licenses/) + // If there is no such translation, the result will be '-' (the empty default + // in the i18n files), so we'll need to force it to look up the actual licenses + // in the default site language (= get the translation from MediaWiki:Licenses) + // Also see https://phabricator.wikimedia.org/T3495 + $defaultMsg = wfMessage( 'licenses' )->inContentLanguage(); + if ( !$defaultMsg->exists() || $defaultMsg->plain() === '-' ) { + $defaultMsg = wfMessage( 'licenses' )->inLanguage( $wgContLang ); + } + + return $defaultMsg->plain(); } /**