Extension:CLDR/zh

Category:Extensions with invalid or missing type/zhCategory:Extensions with unknown license/zh
CLDR
Category:Stable extensions/zh
描述 提供根据语言代码本地化语言、国家、货币和时间单位名称的功能。
作者
最新版本 4.17.0 ()
MediaWiki 1.30+Category:Extensions with manual MediaWiki version/zh
Composer mediawiki/cldrCategory:Extensions supporting Composer/zh
GPL-2.0-or-later, data variant of BSD 3-clauses
下載 -{zh-hans:包含在语言扩展包中 Category:Extensions in Wikimedia version control/zh; zh-hant:包含在語言擴充套組中 Category:Extensions in Wikimedia version control/zh;}-
README
Translatewiki.net
master
前往translatewiki.net翻譯CLDR
Category:All extensions/zh

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

安装

  • 下载,并将解压后的cldr移动到extensions/目录中。
    开发者和代码贡献人员应从Git安装扩展,输入:
    cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/cldr
    
  • 将下列放置在您的LocalSettings.php 的底部:
    wfLoadExtension( 'cldr' );
    
  • Yes 完成 – 在您的wiki上Special:Version,以验证已成功安装

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

更新数据

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

从 CLDR 站点下载最新数据:

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

示例(来自 cldr 目录):

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

用法和

语言名称

CLDR定义了带有一个静态函数getNames()的类LanguageNames。 LanguageNames::getNames接受三个参数:

  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

The language names are best access with MediaWiki core functions:

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


国家名称

CLDR定义了带有一个静态函数getNames()的类CountryNamesCountryNames::getNames接受一个参数:

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

以下示例将一个变量设为CLDR中以法语列出的所有国家的列表。

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


参见

Category:Extensions used on Wikimedia/zh#CLDR/zh Category:Localisation extensions/zh
Category:All extensions/zh Category:Extensions in Wikimedia version control/zh Category:Extensions included in Canasta/zh Category:Extensions included in Fandom/zh Category:Extensions included in Miraheze/zh Category:Extensions included in ProWiki/zh Category:Extensions included in WikiForge/zh Category:Extensions included in wiki.gg/zh Category:Extensions supporting Composer/zh Category:Extensions used on Wikimedia/zh Category:Extensions with invalid or missing type/zh Category:Extensions with manual MediaWiki version/zh Category:Extensions with unknown license/zh Category:GetHumanTimestamp extensions/zh Category:LanguageGetTranslatedLanguageNames extensions/zh Category:Localisation extensions/zh Category:Stable extensions/zh