API:सभी संदेश

This page is a translated version of the page API:Allmessages and the translation is 100% complete.
मीडियाविकि संस्करण:
1.12

सभी या कुछ इंटरफ़ेस संदेशों की सामग्री को सूचीबद्ध करने के लिए GET अनुरोध

API प्रलेख


meta=allmessages (am)

(main | query | allmessages)

Return messages from this site.

Specific parameters:
Other general parameters are available.
ammessages

Which messages to output. * (default) means all messages.

Separate values with | or alternative.
Maximum number of values is 50 (500 for clients that are allowed higher limits).
Default: *
amprop

Which properties to get.

Values (separate with | or alternative): default
amenableparser

Set to enable parser, will preprocess the wikitext of message (substitute magic words, handle templates, etc.).

Type: boolean (details)
amnocontent

If set, do not include the content of the messages in the output.

Type: boolean (details)
amincludelocal

Also include local messages, i.e. messages that don't exist in the software but do exist as in the MediaWiki namespace.

This lists all MediaWiki-namespace pages, so it will also list those that aren't really messages such as Common.js.

Type: boolean (details)
amargs

Arguments to be substituted into message.

Separate values with | or alternative.
Maximum number of values is 50 (500 for clients that are allowed higher limits).
amfilter

Return only messages with names that contain this string.

amcustomised

Return only messages in this customisation state.

One of the following values: all, modified, unmodified
Default: all
amlang

Return messages in this language.

amfrom

Return messages starting at this message.

amto

Return messages ending at this message.

amtitle

Page name to use as context when parsing message (for amenableparser option).

amprefix

Return messages with this prefix.

उदाहरण

GET अनुरोध

किसी संदेश के डच अनुवाद पाएँ।


जवाब

{
    "batchcomplete": "",
    "query": {
        "allmessages": [
            {
                "name": "august",
                "normalizedname": "august",
                "*": "augustus"
            },
            {
                "name": "mainpage",
                "normalizedname": "mainpage",
                "*": "Hoofdpagina"
            },
            {
                "name": "edit",
                "normalizedname": "edit",
                "*": "Bewerken"
            },
            ...
        ]
    }
}

उदाहरण कोड

Python

#!/usr/bin/python3

"""
    all_messages.py
    MediaWiki API Demos
    Demo of `Allmessages` module: Get the Dutch translations of some messages
    MIT License
"""

import requests

S = requests.Session()

URL = "https://en.wikipedia.org/w/api.php"

PARAMS = {
    "action": "query",
    "meta": "allmessages",
    "ammessages": "august|mainpage|edit|rollback-success",
    "amlang": "nl",
    "format": "json"
}

R = S.get(url=URL, params=PARAMS)
DATA = R.json()

print(DATA)

PHP

<?php

/*
    all_messages.php
    MediaWiki API Demos
    Demo of `Allmessages` module: Get the Dutch translations of some messages
    MIT License
*/

$endPoint = "https://en.wikipedia.org/w/api.php";
$params = [
    "action" => "query",
    "meta" => "allmessages",
    "ammessages" => "august|mainpage|edit|rollback-success",
    "amlang" => "nl",
    "format" => "json"
];

$url = $endPoint . "?" . http_build_query( $params );

$ch = curl_init( $url );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
$output = curl_exec( $ch );
curl_close( $ch );

$result = json_decode( $output, true );
var_dump( $result );

JavaScript

/*
    all_messages.js
    MediaWiki API Demos
    Demo of `Allmessages` module: Get the Dutch translations of some messages
    MIT License
*/

var url = "https://en.wikipedia.org/w/api.php"; 

var params = {
    action: "query",
    meta: "allmessages",
    ammessages: "august|mainpage|edit|rollback-success",
    amlang: "nl",
    format: "json"
};

url = url + "?origin=*";
for (var key in params) { url += "&" + key + "=" + encodeURIComponent(params[key]) ;};

fetch(url)
    .then(function(response) { return response.json(); })
    .then(function(response) { console.log(response); })
    .catch(function(error) { console.log(error); });

MediaWiki JS

/*
	all_messages.js
	MediaWiki API Demos
	Demo of `Allmessages` module: Get the Dutch translations of some messages
	MIT License
*/

var params = {
		action: 'query',
		meta: 'allmessages',
		ammessages: 'august|mainpage|edit|rollback-success',
		amlang: 'nl'
	},
	api = new mw.Api();

api.get( params ).done( function ( data ) {
	console.log( data );
} );

पैरमीटरों का इतिहास

  • v1.19: amnocontent, amincludelocal को जोड़ा गया
  • v1.18: amtitle, amprefix, amcustomised को जोड़ा गया
  • v1.17: amto को जोड़ा गया
  • v1.16: amprop, default, amenableparser, amargs को जोड़ा गया
  • v1.15: amfrom को जोड़ा गया