Manual:Interwiki/zh

跨wiki链接（英语：Interwiki links）是指向其他项目的页面的链接，使用前缀内部链接样式.

跨wiki链接可以链接到（例如）维基百科、维基教科书、维基新闻等的页面或你需要的不同语言的wiki项目. （见）.

形如 的链接将这样出现：Main Page，并将您重定向至维基百科的首页.

Interwiki链接到其他项目
Interwiki链接托管在MediaWiki数据库的表中. 该列表可从元数据查询API的interwikimap属性获得，换句话说

默认
默认情况下，几个维基媒体项目（以及其他项目）准备好了进行跨wiki链接，因此您可以在不编辑数据库的情况下使用它们.

以下是一些默认情况下可用的跨wiki前缀的示例（维基百科也可用，1.10及以后）：

缺省列表的完整列表可在中找到

See m:Help:Interwiki linking for complete information on linking from/to Wikimedia projects.

在网页链接中添加新网站

 * 跨Wiki链接在数据库的 表中设定.
 * 要修改这些，您需要编辑数据库，就像下面一样.
 * 您可能比较愿意安装Interwiki扩展，这能够简化上述操作.

由于Wikipedia 默认情况下在1.10版本之前未设置，您可能希望添加它（以及您想要的其他项目）.

下述的示例展示了如何设置 为到英文维基百科的链接.

想法是在表中插入一行：

('prefix', 'URL format string', 1, 0)

到 表中.

单行
高级用户可以使用一条命令行，如下所示：


 * MySQL与PostgreSQL

Newer MediaWiki versions require some extra fields such as.

导出、添加及再导入
Alternatively, you can use the following multi-step process, which exports the  table, adds a line, then re-imports it:

('w', 'https://en.wikipedia.org/wiki/$1', 1, 0);
 * 导出数据库表
 * add to the end of the table a line of the following form (using English wikipedia as an example):


 * Import the database table

要测试
要测试配置：


 * 前往您的网站，
 * create an article, with the following content:
 * This should display a link to the 'Village pump' page on en.Wikipedia.org (the url )
 * This should display a link to the 'Village pump' page on en.Wikipedia.org (the url )

字段文档
In detail, the fields of the  database table are as follows:


 *  : choose a prefix, which is used for interwiki linking, e.g. "wikipedia" for linking to Wikipedia.
 *  : enter the project's URL, e.g.  for Wikipedia. Don't forget the   as it is replaced with the article's name you are linking to (  links to  ).
 *  : enter the project's URL, e.g.  for Wikipedia. Don't forget the   as it is replaced with the article's name you are linking to (  links to  ).
 *  : if 1, your wiki will redirect even external links of the form iw_prefix:title, not only those from its own pages; you need this if you want to use the redirect functionality from outside your wiki or other wikis use your transwiki functions for nested transwiki links (like w:en:fr:Wikipédia:Accueil). See m:Help:Interwiki linking.
 *  : "transwiki transclusion" - set to 1 if you want to use pages from the other wiki as templates. You will also need to set $wgEnableScaryTranscluding = true in your LocalSettings.php
 *  : URL to the MediaWiki API, e.g.  (optional).
 *  : Database name of the wiki (If locally accessible). May be used (later?) for interwiki transclusions. (optional)

参考资料
" as it contains a list of known languages and their prefixes. E.g. you want to add your German project, search " " for "Deutsch" and note the prefix "de".

If you know the "right" prefix, edit your database by adding a new line to table :
 *  : language-prefix (e.g. "de" for German), which is listed in " "
 *  : URL to your wiki-project (e.g. )
 *  : same as above "Adding More"
 *  : same as above "Adding More"

现在，您可以将文章链接到其他语言的相同. Adding  on your English Main_Page will create a link "Deutsch" below the toolbox, which leads to the Main_Page of the German wiki (Hauptseite).

Note, that this link is shown in Sidebar's section, only, and not inside of the article. If you want to create a link inside of the text, you have to add a colon previous to the prefix:  or set $wgInterwikiMagic to false.

Exporting the interwiki table from a wiki
The interwiki table can be queried through the API:Meta module using.

以下JavaScript代码可用于生成SQL INSERT语句，以便在wiki中运行时填充interwiki表，例如，通过浏览器的开发人员工具注入代码或将其放在Special：MyPage / .js和预览：

参见

 * （产生Special:Interwiki）
 * [//www.mediawiki.org/w/api.php?action=query&meta=siteinfo&siprop=interwikimap MediaWiki.org的Interwiki地图]
 * [//www.mediawiki.org/w/api.php?action=query&meta=siteinfo&siprop=interwikimap MediaWiki.org的Interwiki地图]
 * [//www.mediawiki.org/w/api.php?action=query&meta=siteinfo&siprop=interwikimap MediaWiki.org的Interwiki地图]
 * [//www.mediawiki.org/w/api.php?action=query&meta=siteinfo&siprop=interwikimap MediaWiki.org的Interwiki地图]
 * [//www.mediawiki.org/w/api.php?action=query&meta=siteinfo&siprop=interwikimap MediaWiki.org的Interwiki地图]