From 76c888bbc542e65f69554b248cd0959a4402513d Mon Sep 17 00:00:00 2001 From: Matthias Mullie Date: Tue, 6 Mar 2018 18:32:31 +0100 Subject: [PATCH] Fall back to default language when no i18n'ed licenses available Bug: T188822 Change-Id: I5de0167b343c2ce3752f54d2b4418a27aad819c0 --- includes/specials/formfields/Licenses.php | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) 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(); } /** -- 2.20.1