Rozšíření:CLDR

This page is a translated version of the page Extension:CLDR and the translation is 15% complete.
Základní informace k tomuto rozšíření MediaWiki
CLDR
Stav rozšíření: stabilní
Zavádění Funkce analyzátoru
Popis Poskytuje funkce pro lokalizaci názvů jazyků, zemí, měn a časových jednotek na základě jejich jazykového kódu.
Napsal(i)
Nejnovější verze 4.14.0 (Průběžně aktualizováno)
MediaWiki 1.30+
Změny v databázi Ne
Composer mediawiki/cldr
Licence GPL-2.0-or-later, data variant of BSD 3-clauses
Zdrojový kód Zahrnuto v balíčku jazykových rozšíření nebo
README
Příklad Translatewiki.net
master
Používání veřejných wikin 6,625 (Ranked 63rd)
Přeložte rozšíření CLDR, používá-li lokalizaci z translatewiki.net

Rozšíření CLDR obsahuje názvy místních jazyků pro různé jazyky, země, měny a časové jednotky extrahované z dat CLDR. See translatewiki:CLDR for information.


  • Stáhněte soubor/y a vložte je do adresáře pojmenovaného cldr ve vaší složce extensions/.
    Vývojáři a přispěvatelé kódu by si místo toho měli nainstalovat rozšíření from Git pomocí:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/cldr
  • Na konec vašeho souboru LocalSettings.php přidejte následující kód:
    wfLoadExtension( 'cldr' );
    
  • Yes Dokončeno – Přejděte na stránku Special:Version vaší wiki a zkontrolujte, zda bylo rozšíření úspěšně nainstalováno.

If you download from git, change the file from CLDR to cldr.

Updating data

The CLDR extension comes with data pre-populated in the language files, but if you want to get the latest data from the Unicode Consortium, you'll need to download it from the CLDR site and then run a rebuild script.

Download newest data from CLDR site:

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

Example (from within the cldr directory):

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