Extension:CLDR/zh

From Linux Web Expert

Revision as of 03:13, 4 December 2023 by 163.13.9.60 (talk)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

MediaWiki扩展手册
CLDR
发行状态: 稳定版
File:ExampleOfCLDRExtension.png
实现 解析器函数
描述 提供根据语言代码本地化语言、国家、货币和时间单位名称的功能。
作者
MediaWiki 1.30+
数据库更改
Composer mediawiki/cldr
许可协议 GPL-2.0-or-later, data variant of BSD 3-clauses
下載 包含在语言扩展包中
README
示例 Translatewiki.net
master
季度下載量 Lua error in Module:Extension at line 172: bad argument #1 to 'inNamespace' (unrecognized namespace name 'skin').
正在使用的公开wiki数 Lua error in Module:Extension at line 172: bad argument #1 to 'inNamespace' (unrecognized namespace name 'skin').
前往translatewiki.net翻譯CLDR-{zh-hans:扩展; zh-hant:擴充功能}-

CLDR 扩展包含从 CLDR 数据中提取的不同语言、国家、货币和时间单位的本地语言名称。 参见 translatewiki:CLDR 以获取更多信息。


安装

  • <translate> [[<tvar name=2>Special:ExtensionDistributor/cldr</tvar>|Download]] and move the extracted <tvar name=name>cldr</tvar> folder to your <tvar name=ext>extensions/</tvar> directory.</translate>
    <translate> Developers and code contributors should install the extension [[<tvar name=git>Special:MyLanguage/Download from Git</tvar>|from Git]] instead, using:</translate>cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/cldr
  • <translate> Add the following code at the bottom of your <tvar name=1>LocalSettings.php </tvar> file:</translate>
    wfLoadExtension( 'cldr' );
    
  • File:OOjs UI icon check-constructive.svg <translate> Done</translate> – <translate> Navigate to <tvar name=special>Special:Version</tvar> on your wiki to verify that the extension is successfully installed.</translate>

如果您从 git 下载,请将文件从 CLDR 更改为 cldr。

更新数据

CLDR 扩展附带语言文件中预填充的数据,但如果您想从 Unicode Consortium 获取最新数据,则需要从 CLDR 站点下载它,然后运行重构建脚本。

从 CLDR 站点下载最新数据:

http://www.unicode.org/cldr/repository_access.html

示例(来自 cldr 目录):

wget http://www.unicode.org/Public/cldr/latest/core.zip
unzip core.zip -d core
php rebuild.php

Usage and parameters

Language names

CLDR defines the class LanguageNames which has a static method, getNames(). LanguageNames::getNames accepts three parameters:

  1. code - the ISO 639 (see Manual:Language#Language code for details) code of the preferred language to return the list in
  2. fbMethod - fallback method, it should be set to one of the following:
    • LanguageNames::FALLBACK_NATIVE - Missing entries fallback to the native name (default)
    • LanguageNames::FALLBACK_NORMAL - Missing entries fallback through the fallback chain
  3. list - which languages to return. Should be set to one of the following:
    • LanguageNames::LIST_MW_SUPPORTED - Only languages that have localization in MediaWiki
    • LanguageNames::LIST_MW - All languages that are in Names.php (default)
    • LanguageNames::LIST_MW_AND_CLDR - All languages that are either in MediaWiki or in CLDR

Example

The language names are best access with MediaWiki core functions:

// Japanisch
$name = Language::fetchLanguageName( 'ja', 'de', 'all' );

国家名称

CLDR defines the class CountryNames which has a static method, getNames(). CountryNames::getNames accepts one parameter:

  1. code - the ISO 639 code of the preferred language to return the list in

The following example sets a variable to the list of all countries in CLDR in French.

if ( is_callable( array( 'CountryNames', 'getNames' ) ) ) {
    $countries = CountryNames::getNames( 'fr' );
}


参见

This message box is using an invalid "type=parser function" parameter and needs fixing.