ResourceBundle
class ResourceBundle implements IteratorAggregate, Countable (View source)
Localized software products often require sets of data that are to be customized depending on current locale, e.g.: messages, labels, formatting patterns. ICU resource mechanism allows to define sets of resources that the application can load on locale basis, while accessing them in unified locale-independent fashion.
This class implements access to ICU resource data files. These files are binary data arrays which ICU uses to store the localized data. ICU resource bundle can hold simple resources and complex resources. Complex resources are containers which can be either integer-indexed or string-indexed (just like PHP arrays). Simple resources can be of the following types: string, integer, binary data field or integer array. ResourceBundle supports direct access to the data through array access pattern and iteration via foreach, as well as access via class methods. The result will be PHP value for simple resources and ResourceBundle object for complex ones. All resources are read-only.
Methods
Create a resource bundle
(PHP >= 5.3.2, PECL intl >= 2.0.0)
Create a resource bundle
(PHP >= 5.3.2, PECL intl >= 2.0.0)
Get data from the bundle
(PHP >= 5.3.2, PECL intl >= 2.0.0)
Get number of elements in the bundle
(PHP >= 5.3.2, PECL intl >= 2.0.0)
Get supported locales
(PHP >= 5.3.2, PECL intl >= 2.0.0)
Get bundle's last error code.
(PHP >= 5.3.2, PECL intl >= 2.0.0)
Get bundle's last error message.
No description
Details
__construct(string $locale, string $bundle, bool $fallback = true)
Create a resource bundle
Creates a resource bundle.
static ResourceBundle|null
create(string $locale, string $bundle, bool $fallback = true)
(PHP >= 5.3.2, PECL intl >= 2.0.0)
Create a resource bundle
mixed
get(string|int $index, bool $fallback = true)
(PHP >= 5.3.2, PECL intl >= 2.0.0)
Get data from the bundle
int
count()
(PHP >= 5.3.2, PECL intl >= 2.0.0)
Get number of elements in the bundle
static array|false
getLocales(string $bundle)
(PHP >= 5.3.2, PECL intl >= 2.0.0)
Get supported locales
int
getErrorCode()
(PHP >= 5.3.2, PECL intl >= 2.0.0)
Get bundle's last error code.
string
getErrorMessage()
(PHP >= 5.3.2, PECL intl >= 2.0.0)
Get bundle's last error message.
Traversable
getIterator()
No description