ResourceBundle返回NULL,而不会引发任何错误 [英] ResourceBundle returns NULL without any errors being raised
问题描述
对于国际化数据,最好使用PHP的"intl"扩展名的\ResourceBundle
类.
For internationalized data it would be great to work with the \ResourceBundle
class from PHP's "intl" extension.
我运行了扩展程序(PHP 5.3.4; Windows),并使用 ICU数据库自定义程序 *,但我从资源包类中没有得到预期的结果.
I got the extension running (PHP 5.3.4; Windows) and created a .dat file using the ICU Data Library Customizer*, but I don't get the expected result from the resource bundle class.
现在我这样做
$bundle = '/var/www/libs/icudt48l.dat';
$resource = new \ResourceBundle('en_US', $bundle, true);
var_dump($resource, is_file($bundle)); //--> NULL, TRUE
问题是$resource
返回NULL而没有引发任何错误.发生了什么事?
The problem is $resource
returns NULL without any errors being raised. What's going on?
*(仅检查了最后两个数据部分-始终包含基础数据-并且我将其导出为ICU4C)
*(Only the last two data sections were checked—base data is always included—and I exported it as ICU4C)
推荐答案
<?php
$b = '/var/www/libs/icudt48l';
$r = new \ResourceBundle('en_US', $b, true);
var_dump($r instanceof \ResourceBundle); //-> TRUE
应保留.dat扩展名以使其起作用
the .dat extension should be left to make it work
这篇关于ResourceBundle返回NULL,而不会引发任何错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!