首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

ResourceBundle (class)

Introduction

(PHP >= 5.3.2, 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 synopsis

ResourceBundle {

/* Methods */

public __construct ( string $locale , string $bundlename , bool $fallback )

代码语言:javascript
复制
public int count ( void )
代码语言:javascript
复制
public static ResourceBundle create ( string $locale , string $bundlename [, bool $fallback ] )
代码语言:javascript
复制
public int getErrorCode ( void )
代码语言:javascript
复制
public string getErrorMessage ( void )
代码语言:javascript
复制
public mixed get ( string|int $index [, bool $fallback = TRUE ] )
代码语言:javascript
复制
public array getLocales ( string $bundlename )

}

See Also

Table of Contents

  • ResourceBundle::count — Get number of elements in the bundle
  • ResourceBundle::create — Create a resource bundle
  • ResourceBundle::getErrorCode — Get bundle's last error code.
  • ResourceBundle::getErrorMessage — Get bundle's last error message.
  • ResourceBundle::get — Get data from the bundle
  • ResourceBundle::getLocales — Get supported locales

← IntlDateFormatter::setTimeZone

ResourceBundle::count →

代码语言:txt
复制
 ? 1997–2017 The PHP Documentation Group

Licensed under the Creative Commons Attribution License v3.0 or later.

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com