PHP 8.4.1 Released!

ResourceBundle::getLocales

resourcebundle_locales

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

ResourceBundle::getLocales -- resourcebundle_localesGet supported locales

Description

Object-oriented style

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

Procedural style

resourcebundle_locales(string $bundle): array|false

Get available locales from ResourceBundle name.

Parameters

bundle

Path of ResourceBundle for which to get available locales, or empty string for default locales list.

Return Values

Returns the list of locales supported by the bundle, or false on failure.

Examples

Example #1 resourcebundle_locales() example

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

The above example will output something similar to:

es
root

Example #2 OO example

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

The above example will output something similar to:

es
root

See Also

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):

<?php
print_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