API: Make uselang=user the default
authorBrad Jorsch <bjorsch@wikimedia.org>
Tue, 4 Nov 2014 21:42:43 +0000 (16:42 -0500)
committerOri.livneh <ori@wikimedia.org>
Tue, 4 Nov 2014 23:09:07 +0000 (23:09 +0000)
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
includes/api/ApiMain.php
includes/api/i18n/en.json

index 7a088cf..aa0d5a7 100644 (file)
@@ -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.
index f7588a3..10a99c9 100644 (file)
@@ -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',
                        ),
                );
        }
index 485c776..4fbfb40 100644 (file)
@@ -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.",