From d0cb475f1eed27631a7e9049fd20531ef9208dd5 Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Tue, 4 Nov 2014 16:42:43 -0500 Subject: [PATCH] API: Make uselang=user the default After consultation, it is thought that the reduced cacheability won't be an issue. This also adds "uselang=content" as an option since it's no longer the default. Change-Id: Idc24bfc8bff7392c2047a6b856760ad26a4e9800 --- RELEASE-NOTES-1.25 | 7 +++---- includes/api/ApiMain.php | 7 ++++--- includes/api/i18n/en.json | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/RELEASE-NOTES-1.25 b/RELEASE-NOTES-1.25 index 7a088cfd74..aa0d5a7b16 100644 --- a/RELEASE-NOTES-1.25 +++ b/RELEASE-NOTES-1.25 @@ -76,10 +76,9 @@ production. * Hitting api.php without specifying an action now displays only the help for the main module, with links to submodule help. * API help is no longer displayed on errors. -* Internationalized messages returned by the API will be in the wiki's content - language by default. 'uselang' is now a recognized API parameter; - "uselang=user" may be used to select the language from the current user's - preferences. +* 'uselang' is now a recognized API parameter; "uselang=user" may be used to + explicitly select the language from the current user's preferences, and + "uselang=content" may be used to select the wiki's content language. * Default output format for the API is now jsonfm. * Simplified continuation will return a "batchcomplete" property in the result when a batch of pages is complete. diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index f7588a3a62..10a99c9fb0 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -192,6 +192,9 @@ class ApiMain extends ApiBase { $uselang = $this->getUser()->getOption( 'language' ); $uselang = RequestContext::sanitizeLangCode( $uselang ); wfRunHooks( 'UserGetLanguageObject', array( $this->getUser(), &$uselang, $this ) ); + } elseif ( $uselang === 'content' ) { + global $wgContLang; + $uselang = $wgContLang->getCode(); } $code = RequestContext::sanitizeLangCode( $uselang ); $this->getContext()->setLanguage( $code ); @@ -1121,8 +1124,6 @@ class ApiMain extends ApiBase { * @return array */ public function getAllowedParams() { - global $wgContLang; - return array( 'action' => array( ApiBase::PARAM_DFLT => 'help', @@ -1151,7 +1152,7 @@ class ApiMain extends ApiBase { 'curtimestamp' => false, 'origin' => null, 'uselang' => array( - ApiBase::PARAM_DFLT => $wgContLang->getCode(), + ApiBase::PARAM_DFLT => 'user', ), ); } diff --git a/includes/api/i18n/en.json b/includes/api/i18n/en.json index 485c7763e1..4fbfb40ffc 100644 --- a/includes/api/i18n/en.json +++ b/includes/api/i18n/en.json @@ -16,7 +16,7 @@ "apihelp-main-param-servedby": "Include the hostname that served the request in the results.", "apihelp-main-param-curtimestamp": "Include the current timestamp in the result.", "apihelp-main-param-origin": "When accessing the API using a cross-domain AJAX request (CORS), set this to the originating domain. This must be included in any pre-flight request, and therefore must be part of the request URI (not the POST body). This must match one of the origins in the Origin: header exactly, so it has to be set to something like http://en.wikipedia.org or https://meta.wikimedia.org. If this parameter does not match the Origin: header, a 403 response will be returned. If this parameter matches the Origin: header and the origin is whitelisted, an Access-Control-Allow-Origin header will be set.", - "apihelp-main-param-uselang": "Language to use for message translations. A list of codes may be fetched from [[Special:ApiHelp/query+siteinfo|action=query&meta=siteinfo&siprop=languages]], or specify \"user\" to use the current user's language preference.", + "apihelp-main-param-uselang": "Language to use for message translations. A list of codes may be fetched from [[Special:ApiHelp/query+siteinfo|action=query&meta=siteinfo]] with siprop=languages, or specify \"user\" to use the current user's language preference, or specify \"content\" to use this wiki's content language.", "apihelp-block-description": "Block a user.", "apihelp-block-param-user": "Username, IP address or IP range you want to block.", -- 2.20.1