API:PageLanguage
From MediaWiki.org
| This page is part of the MediaWiki action API documentation. |
MediaWiki action API
- Introduction and quick start
- FAQ
- Tutorial
- Formats
- Error reporting
- Restricting usage
- Cross-site requests
- Authentication
- Queries
- Searching (by title, content, coordinates...)
- Parsing wikitext and expanding templates
- Purging pages' caches
- Parameter information
- Changing wiki content
- Watchlist feed
- Wikidata
- Extensions
- Using the API in MediaWiki and extensions
- Miscellaneous
- Implementation
- Client code
- Asserting
| MediaWiki version: | 1.24 |
Token[edit]
To change the page language for a page, an edit token is required via action=tokens or by using the following method:
Obtaining a token
| Result |
|---|
<?xml version="1.0"?>
<api>
<tokens edittoken="2efb624b1c9fde05eb8d7f84be441673+\" />
</api>
|
Changing page language[edit]
The language for a page can be changed using action=pagelang.
Parameters[edit]
titles: A list of titleslang: The target language for the page(s), if not set taken as default wiki language.token: The token obtained in the previous request. Take care to urlencode the+as%2B.
Don't forget to append = even to parameters with no value, for example &lang doesn't work, &lang= does work
Example[edit]
Note: In this example, all parameters are passed in a GET request just for the sake of simplicity. However, action=pagelang requires POST requests; GET requests will cause an error.
Changing page language for Project:Sandbox & Main Page
api.php? action=pagelang& titles=Project%3ASandbox|Main_Page& token=bffd6f4fbd23ed07254ec3cec8fa69da%2B\ [try in ApiSandbox]
Possible errors[edit]
In addition to the usual stuff:
| Code | Info |
|---|---|
| notoken | The token parameter must be set |
| badlanguage-code | The language code is not valid |
| nopagetext | The page doesn't exist |
| page-changelang-nopermission | User doesn't have permission to change the language or the page language change isn't allowed. |
| changelang-none | No change in the page language, the old and the new languages are same. |
| changelang-fail | The language change failed. |

