]> granicus.if.org Git - php/commitdiff
implement FR #54540 - Allow loading of arbitrary resource bundles when fallback is...
authorStanislav Malyshev <stas@php.net>
Sun, 17 Apr 2011 21:56:26 +0000 (21:56 +0000)
committerStanislav Malyshev <stas@php.net>
Sun, 17 Apr 2011 21:56:26 +0000 (21:56 +0000)
NEWS
ext/intl/resourcebundle/resourcebundle_class.c
ext/intl/tests/resourcebundle_create.phpt
ext/intl/tests/resourcebundle_internal.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 2577a1fbf3430b9f041d923253096cb8f2fe79bf..a9bea7905b9c2e41ded76a3d4417b91cbbd63edc 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -42,6 +42,10 @@ PHP                                                                        NEWS
 - Filter extension:
   . Fixed bug #53037 (FILTER_FLAG_EMPTY_STRING_NULL is not implemented). (Ilia)
   
+- intl extension:
+  . Implemented FR #54540 (Allow loading of arbitrary resource bundles when
+    fallback is disabled). (David Zuelke, Stas)
+
 - LDAP extension:
   . Fixed bug #53339 (Fails to build when compilng with gcc 4.5 and DSO
     libraries). (Clint Byrum, Raphael)
index a8a4bf1c86be0ab7bd2ed467d7e9e36d6b54d8b8..67d0e55ddd44d86e7518c52aeb4fde97e17ffb0e 100644 (file)
@@ -102,7 +102,11 @@ static void resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS)
 
        INTL_CHECK_LOCALE_LEN_OBJ(locale_len, return_value);
 
-       rb->me = ures_open(bundlename, locale, &INTL_DATA_ERROR_CODE(rb));
+       if (fallback) {
+               rb->me = ures_open(bundlename, locale, &INTL_DATA_ERROR_CODE(rb));
+       } else {
+               rb->me = ures_openDirect(bundlename, locale, &INTL_DATA_ERROR_CODE(rb));
+       }
 
        INTL_CTOR_CHECK_STATUS(rb, "resourcebundle_ctor: Cannot load libICU resource bundle");
 
index 4d96d3eff773c020df3e88a7a1ab911108f8bcee..2bf4f556a8609515fd000361680925315c23a201 100644 (file)
@@ -57,6 +57,6 @@ ResourceBundle Object
 
  -127: U_USING_DEFAULT_WARNING
 NULL
- -127: resourcebundle_ctor: Cannot load libICU resource '%s/resourcebundle' without fallback from en_US to root: U_USING_DEFAULT_WARNING
+    2: resourcebundle_ctor: Cannot load libICU resource bundle: U_MISSING_RESOURCE_ERROR
 NULL
     2: resourcebundle_ctor: Cannot load libICU resource bundle: U_MISSING_RESOURCE_ERROR
diff --git a/ext/intl/tests/resourcebundle_internal.phpt b/ext/intl/tests/resourcebundle_internal.phpt
new file mode 100644 (file)
index 0000000..7aefd85
--- /dev/null
@@ -0,0 +1,19 @@
+--TEST--
+Test ResourceBundle::__construct() with internal ICU bundles
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+$b = new ResourceBundle('de_DE', 'ICUDATA-region');
+var_dump($b->get('Countries')->get('DE'));
+
+$b = new ResourceBundle('icuver', 'ICUDATA');
+var_dump($b->get('ICUVersion') !== NULL);
+
+$b = new ResourceBundle('supplementalData', 'ICUDATA', false);
+var_dump($b->get('cldrVersion') !== NULL);
+?>
+--EXPECTF--
+string(11) "Deutschland"
+bool(true)
+bool(true)