Extension:Wikibase Client

Wikibase Client is an extension that acts as a client to the Wikibase extension. Its development is part of the Wikidata project.

Currently (April 2012), Wikibase Client can fetch interlanguage links from a Wikibase repository via the API and display them on the client wiki, sorted by the client's preferred sorting. It is in plan to also be able to edit the links on the repository from a client wiki, fetch other kinds of data besides links, manage updating of articles and have other related functionality.

Requirements
requires:


 * MediaWiki 1.20 or above
 * WikibaseLib
 * PHP 5.3 or above

Installation
Once you have downloaded the code, place the WikibaseClient directory within your MediaWiki 'extensions' directory. Then add the following code to your LocalSettings.php file:

For testing purposes, you may use maintenance/populateInterwiki.php script which will populate interwiki table of your wiki with interwikis from English Wikipedia. This means that you will have all the Wikipedia language links ready for testing.

Configuration
Configuration of is done by assigning to members of $egWBCSettings array in your LocalSettings.php file. The options are listed below and their default is set in the settings file. You should NOT modify the settings file, but can have a look at it to get an idea of how to use the settings, in case the below descriptions do not suffice.

An example of how to change the settings:

Available settings:

Usage
After the extension is installed, it will try to fetch interlanguage links from the central Wikibase repository whenever a page is parsed (on Show Preview, save or purge). The links are fetched via the API from the item on the central wiki that has the interlanguage link to the article on the client wiki. The extension will then sort the links (sorting defined per-wiki), and display them, and save them to the database, just as if they are defined on the page. The extension is robust and will keep the existing links in case the central wiki is down.

By default the extension only works in the main namespace, but it is possible to change this with namespaces configuration option.

Mixing Wikidata and local interlanguage links
The extension doesn't interfere with usual working of interlanguage links. They may continue to be used in parallel to the extension. There are several use cases:


 * Links on pages in namespaces which are not configured to use the extension continue to work exactly as without the extension.
 * If you want to add links in addition to the links stored in Wikidata, simply add new links in wikitext, they will be added to the links from Wikidata, and all the links will be displayed together.
 * If you want to not show some of the links from Wikidata you can use noexternalinterlang parser function with the desired language(s). Other links will continue to work normally.
 * If you want to overwrite some links from Wikidata, you can likewise use noexternalinterlang parser function and add the new links in wikitext.
 * If you want to turn off Wikidata link completely, you can use the noexternalinterlang magic word. In this case the links won't even be sorted, but will continue to work exactly as without the extension.

noexternalinterlang
noexternalinterlang (short for "no external interlanguage") is a magic word and a parser function which can turn this extension off for a specific page, or suppress some of the interlanguage links produced by the extension.

If used on its own, as, it will turn this extension off on the page. Only the interlanguage links that are present in the wikitext will be used. Sorting of the links will also be turned off, unless alwaysSort option is turned on. The same effect is achieved if it is used as a function, with an asterisk: (asterisk "matches" all the languages).

If used as a function, with parameters, only the links to the languages of the parameters will be removed. For example, will remove the links to French and Indonesian languages. Same effect can be achieved by invoking the function repeatedly:. Note that the remaining links will now be sorted, which means that wikitext links will be sorted even if French and Indonesian links were the only ones existing. It is safe to remove the link of a non-existing language.

source
Array. A one-member array where the key is the way the links will be fetched and the value is appropriate place they will be fetched from.

The key could be:
 * - fetch links from a Wikidata API. The value should be base URL of the API.
 * - fetch links from a PHP variable. The value should be an array where keys are article names and values are arrays of language links. This is used for testing. No value simulates a non-working server.
 * - fetch links from a directory of JSON files. The value should be the path to the directory. This is used for development and testing. File  may be used as a template for the files. A lack of file simulates a non-working server.

Default: the extension will try to get the links from the  directory.

namespaces
Array. An array of namespaces in which the extension will work.

Default: the extension will work only in the main namespace.

sort
String. Selects the sort method you want to use for the interlanguage links. Currently, it recognizes four sort methods:
 * 'code': By language code (auto-languagecode)
 * 'alphabetic': By language name (meta-native-languagename)
 * 'alphabetic_revised': By language name (alternative) (meta-native-languagename-firstword</tt>)
 * 'none'</tt>: Don't sort. Basically, the order of the links is not guaranteed.

Default: 'none'</tt> sort mode.

sortPrepend
Array. Modifies the sort method so that it sorts certain languages at the top of the list of languages, regardless of their general sort order. It should be set to an array that has values set to desired language codes, in desired order. For example, to put English and then Simple English at the top of the list of languages, set it to array( 'en', 'simple' )</tt>. It is even possible to make an entire custom sort array with all the languages, that will completely override any of the sorting methods.

Default: the sort will be used unmodified.

alwaysSort
Boolean. Always sort the links, even when the extension is not used.

By default, the extension will not sort the links if it is not used: whether on pages outside of the defined namespaces, or if it is suppressed by the noexternalinterlang magic word. In these cases, by default, the links on the page will be shown in order they are in wikitext, which is the MediaWiki default. However, if alwaysSort is turned on (set to true), then the links will be sorted even if these cases.

Note that even if alwaysSort is off, the extension will still sort the links if there are no links in the repository, or each of the links is individually suppressed by noexternalinterlang.

Default: don't always sort.

Version
This is a copy of the release notes file on GIT, which might be more up to date then this page.

Internationalization
is fully internationalized. Translation of messages is done through translatewiki.net. The translation for this extension can be found here. To add language values or change existing ones, you should create an account on translatewiki.net, then request permission from the administrators to translate a certain language or languages on this page (this is a very simple process). Once you have permission for a given language, you can log in and add or edit whatever messages you want to in that language.