ResourceBundle::getLocales

resourcebundle_locales

(PHP 5 >= 5.3.2, PHP 7, PHP 8, PECL intl >= 2.0.0)

ResourceBundle::getLocales -- resourcebundle_localesサポートするロケールを取得する

説明

オブジェクト指向型

public static ResourceBundle::getLocales(string $bundle): array|false

手続き型

resourcebundle_locales(string $bundle): array|false

ResourceBundle 名を指定して、サポートするロケールを取得します。

パラメータ

bundle

ロケールを取得したい ResourceBundle のパス、あるいは 空文字列を指定するとデフォルトのロケール一覧を取得できます。

戻り値

このバンドルがサポートするロケールの一覧を返します。 失敗した場合は false を返します。

例1 resourcebundle_locales() の例

<?php
$bundle
= "/user/share/data/myapp";
echo
join(PHP_EOL, resourcebundle_locales($bundle));
?>

上の例の出力は、 たとえば以下のようになります。

es
root

例2 オブジェクト指向の例

<?php
$bundle
= "/usr/share/data/myapp";
$r = new ResourceBundle( 'es', $bundle);
echo
join("\n", $r->getLocales($bundle));
?>

上の例の出力は、 たとえば以下のようになります。

es
root

参考

add a note

User Contributed Notes 1 note

up
6
jared at enhancesoft dot com
10 years ago
If you call this method with an empty string, it will return a list of all locales available in the ICU library (via the intl extension):<?phpprint_r(ResourceBundle::getLocales('')); /* Output might show  * Array  * (  *    [0] => af  *    [1] => af_NA  *    [2] => af_ZA  *    [3] => am  *    [4] => am_ET  *    [5] => ar  *    [6] => ar_AE  *    [7] => ar_BH  *    [8] => ar_DZ  *    [9] => ar_EG  *    [10] => ar_IQ  *  ...  */?>
To Top