Locale::lookup

locale_lookup

(PHP 5 >= 5.3.0, PHP 7, PHP 8, PECL intl >= 1.0.0)

Locale::lookup -- locale_lookupEn iyi eşleşen dili bulmak için dil yaftası listesini araştırır

Açıklama

Nesne yönelimli kullanım

public static Locale::lookup(
    array $dil_yaftası,
    string $yerel,
    bool $meşru = false,
    ?string $öntanımlı_yerel = null
): ?string

Yordamsal kullanım

locale_lookup(
    array $dil_yaftası,
    string $yerel,
    bool $meşru = false,
    ?string $öntanımlı_yerel = null
): ?string

RFC 4647'nin arama algoritmasına uygun olarak, yerel ile belirtilen dil aralığı ile en iyi eşleşen dil yaftasını dil_yaftası içindeki öğeler arasında arar.

Bağımsız Değişkenler

dil_yaftası

yerel ile karşılaştırılacak dil yaftalarının listesini içeren bir dizi. En fazya 100 öğeye izin verilir.

yerel

Dil aralığını eşleştirmek için kullanılacak yerel.

meşru

true ise bağımsız değişkenler eşleştirilmeden önce meşru biçeme dönüştürülür.

öntanımlı_yerel

Bir eşleşme bulunamadığı takdirde kullanılacak yerel.

Dönen Değerler

Bulunduğu takdirde en iyi eşleşen dil yaftası, aksi takdirde öntanımlı değer döner.

yerel INTL_MAX_LOCALE_LEN'den uzunsa null döner.

Sürüm Bilgisi

Sürüm: Açıklama
7.4.0 öntanımlı_yerel artık null olabiliyor.

Örnekler

Örnek 1 - locale_lookup() örneği

<?php
$arr
= array(
'de-DEVA',
'de-DE-1996',
'de',
'de-De'
);
echo
locale_lookup($arr, 'de-DE-1996-x-prv1-prv2', true, 'en_US');
?>

Örnek 2 - Nesne yönelimli kullanım örneği

<?php
$arr
= array(
'de-DEVA',
'de-DE-1996',
'de',
'de-De'
);
echo
Locale::lookup($arr, 'de-DE-1996-x-prv1-prv2', true, 'en_US');
?>

Yukarıdaki örneğin çıktısı:

de_de_1996

Ayrıca Bakınız

add a note

User Contributed Notes 2 notes

up
2
vladimir at bashkirtsev dot com
9 years ago
It worth to note that if $langtag array is empty this function returns empty string and not $default . Use array(false) if your $langtag array is empty in order to get default locale.
up
1
Anonymous
8 years ago
Note that this method does not understand "similar" languages, so the following:

Locale::lookup(["en-US"], "en-GB", false);
Or:
Locale::lookup(["es-ES"], "es-CO", false);

Does not work as you would expect (empty result). To get a match in those cases you will have to use two letter language codes instead:

Locale::lookup(["en"], "en-GB", false);
Or:
Locale::lookup(["es"], "es-CO", false);

These do return 'en' and 'es' respectively.
To Top