Jump to content

Extension:CLDR

From DawoumWiki, the free Mathematics self-learning

CLDR 확장은 CLDR 데이터에서 추출된 다양한 언어, 국가, 통화 및 시간 단위에 대한 현지 언어 이름을 포함하고 있습니다. 자세한 내용에 대해 translatewiki:CLDR을 참조하십시오.

Installation

미디어위키 확장 내려받기 지면에서 해당하는 버전을 다운로드하고 위키의 extensions 디렉토리에 cldr에 푸십시오.

또는 개발자와 코드 기여자는 대신 다음을 사용하여 Git에서 확장 프로그램을 설치해야 합니다.

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

미디어위키 설정 LocalSettings.php에 다음을 추가하십시오:

wfLoadExtension( 'cldr' );

Special:Version에 접근해서 확장이 정상적으로 설치가 되었는지 확인하십시오.

만약 git에서 다운로드하면, 파일을 CLDR에서 cldr로 변경하십시오.

Updating data

CLDR 확장은 언어 파일에 미리 채워진 데이터와 함께 제공되지만, 만약 유니코드 컨소시엄에서 최신 데이터를 얻으려면, 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' );

Country names

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

Example

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' );
}


See also