哈希空间 Ctrl + F 进行搜索
首页 php手册中文版 CSS中文手册 哈希文档 Markdown在线工具

PHP resourcebundle 组件

The ResourceBundle class

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

简介

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.

类摘要

class ResourceBundle implements IteratorAggregate, Countable {
/* 方法 */
public __construct(?string $locale, ?string $bundle, bool $fallback = true)
public count(): int
public static create(?string $locale, ?string $bundle, bool $fallback = true): ?ResourceBundle
public getErrorCode(): int
public getErrorMessage(): string
public get(string|int $index, bool $fallback = true): mixed
public static getLocales(string $bundle): array|false
}

更新日志

版本 说明
8.0.0 ResourceBundle implements IteratorAggregate now. Previously, Traversable was implemented instead.
7.4.0 ResourceBundle implements Countable now.

目录

打开 哈希空间 微信小程序中查看更佳