扩展程序:巴别

From MediaWiki.org
Jump to navigation Jump to search
This page is a translated version of the page Extension:Babel and the translation is 34% complete.

Other languages:
Deutsch • ‎English • ‎Lëtzebuergesch • ‎Scots • ‎asturianu • ‎català • ‎dansk • ‎español • ‎français • ‎italiano • ‎lietuvių • ‎magyar • ‎polski • ‎português • ‎português do Brasil • ‎sicilianu • ‎suomi • ‎български • ‎русский • ‎العربية • ‎हिन्दी • ‎মেইতেই লোন্ • ‎中文 • ‎日本語 • ‎조선말 • ‎한국어
MediaWiki扩展手册
Crystal Clear action run.svg
Babel
发布状态: 稳定版
Babel-extension-screenshot.png
实现 Parser extension
描述 Adds a parser function to inform other users about language proficiency and categorize users of the same levels and languages.
作者 Robert Leverington (RobertLtalk)
最新版本 Continuous updates
MediaWiki 1.30+
数据更新
Composer mediawiki/babel
许可协议 GNU General Public License 2.0 or later
下载 包括于语言扩展链
例子 Translatewiki.net
参数
  • $wgBabelCategorizeNamespaces
  • $wgBabelCategoryNames
  • $wgBabelMainCategory
  • $wgBabelDefaultLevel
  • $wgBabelUseUserLanguage
  • $wgBabelUseDatabase
  • $wgBabelCentralDb
  • $wgBabelCentralApi
使用的钩子
ParserFirstCallInit
LinksUpdate
LoadExtensionSchemaUpdates
UserGetReservedNames
翻译Babel扩展如果在translatewiki.net可用
检查使用和版本矩阵。
问题 开放的工作 · 报告错误
警告 警告: 巴别扩展与网络更新器(web updater)不兼容。 如果您需要在您的wiki上使用网络更新器,请首先将此扩展从LocalSettings.php中禁用,运行网络更新器,然后重新启用它。 参见任务T69877

The Babel extension adds a parser function to replace the old Babel system that completely relied on templates. If an unrecognized language parameter is specified, it will see if there is an existing template with the name and include that.

On Wikimedia projects, the noun Babel (in reference to the Tower of Babel) refers to the texts on user pages aiding multilingual communication by making it easier to contact someone who speaks a certain language. The idea originated on the Wikimedia Commons and has also been implemented on many other wikis.

下载

此扩展可直接从Git检索到 [?]:

  • 浏览代码
  • 部分扩展有稳定版本标签。
  • 每个分支与过去的MediaWiki发布版本相关联。 这里也有一个“主线”分支,包含最新alpha版本(可能需要MediaWiki的alpha版本)。

提取快照,并将它放置在您的MediaWiki安装副本的extensions/Babel/目录中。

如果您对git熟悉,并且拥有您服务器的shell访问权,您也可以通过以下方法获得扩展:

cd extensions/
git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/Babel.git

安装

  • 下载文件,并将其放置在您extensions/文件夹中的Babel目录内。
  • 将下列代码放置在您的LocalSettings.php的底部:
    wfLoadExtension( 'Babel' );
    
  • Configure as required.
  • Yes 完成 – 在您的wiki上导航至Special:Version,以验证扩展已成功安装。

致使用MediaWiki 1.25或更早版本的用户:

上面的说明介绍的是安装此扩展的新方法,它使用wfLoadExtension() 如果您需要在早期版本(MediaWiki 1.25和更早版本)中安装此扩展,而不是wfLoadExtension( 'Babel' );,您需要使用:

require_once "$IP/extensions/Babel/Babel.php";
  • The CSS is located in the file resources/ext.babel.css. You can change the style as desired by overriding them in the page MediaWiki:Common.css.
  • If the CLDR extension is found language names are taken from that (where translations are unavailable), otherwise built in MediaWiki language names and English defaults are used.

用法

Syntax for the #babel parser function is as follows:

 {{#babel: babelcode1 | babelcode2 | ... }}

Add one of the following codes for each language you speak or understand, separated by |, where xx is the MediaWiki language code, ISO 639-1 code, or ISO 639-3 code for the language. The general usage of each code level is as follows:

xx-0:如果您对此种语言一窍不通。
xx-1:初级水平——您对此种语言的写作或会话略懂一二。
xx-2
Intermediate ability - enough for editing or discussions.
xx-3
Advanced level - though you can write in this language with no problem, some small errors might occur.
xx-4
"Near-native" level - although it's not your first language from birth, your ability is something like that of a native speaker.
xx-5:专业水平。
xxxx-N:您是这种语言的母语用户,您天生就可以使用该语言的俗话和/或俚语。

To include any other template, simply add the name of the template, e.g. add User from London if you want to include Template:User from London. A prefix or suffix may be added to template names (e.g. User at the beginning) depending on the local configuration, this can be used to restrict the selection and reduce the length of parameters; for example from London could include Template:User from London if configured in such a way.

To remove the header and footer, use plain=1 as the first parameter, e.g. {{#babel: plain=1 | babelcode1 | babelcode2 | ... }}. This makes it easier to use babel with other userboxes.

配置

Configuration parameters

Babel has six configuration parameters which can be modified in LocalSettings.php.

$wgBabelLanguageCodesCdb 
(string) the path of the language code database file, the default should suffice.
$wgBabelLanguageNamesCdb 
(string) the path of the language name database file, the default should suffice.
$wgBabelCategoryNames 
(array of string or boolean, indexed by the strings "1", "2", … "5", "N") where each entry is the name of a category for the skill level indicated by its index, possible variable elements are: %code% (language code), %wikiname% (the name of the language in the wiki's content language), and %nativename% (the name of the language in its language). To disable adding a category for a particular level, set the corresponding value to false.
例如:
$wgBabelCategoryNames = array(
	'0' => 'User %code%-0',
	'1' => 'User %code%-1',
	'2' => 'User %code%-2',
	'3' => 'User %code%-3',
	'4' => 'User %code%-4',
	'5' => 'User %code%-5',
	'N' => 'User %code%-N',
);
will use categories like "Category:User en-0" and "Category:User fr-N". The default is just "Category:Fr-N" and so on.
$wgBabelMainCategory 
(string) Name of the main (non-level) category for each language, to which all users of that language are added. Set to false to disable; defaults to format "Category:Fr". It accepts the same format as $wgBabelCategoryNames above. Example:
$wgBabelMainCategory = 'User %code%';
$wgBabelDefaultLevel 
(string) Default ability level to use when none is specified, should be an index from $wgBabelCategoryNames, that is one of the strings "1", "2", … "5", "N". Default is "N".
$wgBabelUseUserLanguage 
(boolean) Whether to use the user interface language for the header and footer message. If false (default), it will be in the page content language. This is because using the user interface language may fragment the parser cache.

System messages

Several customizations can also be made using MediaWiki namespace messages.

MediaWiki:babel-template "Template:User $1"
The format of template names when one is being included.
MediaWiki:babel-portal "⧼babel-portal⧽"
The format of the target of the link from the language code.
MediaWiki:Babel-autocreate-user "Babel AutoCreate"
Username to be used for autocreation of Babel related categories
MediaWiki:babel-autocreate-text-levels "在此分类中的用户具有$2的$1级能力。"
Text to insert into auto-created categories for different language levels. You have to change this if you want them to be auto-categorized in the main category of the respective language ($wgBabelMainCategory).
MediaWiki:babel-autocreate-text-main "此分类中的用户能理解$1。"
Text to insert into auto-created categories for non-level categories. You have to change this if you want them to be auto-categorized in a parent category for all languages.
MediaWiki:babel "用户巴别信息"
巴别框的页顶
MediaWiki:babel-url "Project:巴別"
The pagename where information on the babel extension can be found
MediaWiki:Babel-footer "用户(按语言)"
巴别框的页脚
MediaWiki:babel-footer-url " :Category:巴别-用户(按语言)"
The page to link to in the footer of the babel box

API

meta=babel (bab)

(main | query | babel)

Get information about what languages the user knows

Parameter:
babuser

User to get information about

This parameter is required.
Type: user name
Example:
Get the Babel information for user Example
api.php?action=query&meta=babel&babuser=Example [open in sandbox]