stas Sun, 17 Apr 2011 21:56:26 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=310293
Log: implement FR #54540 - Allow loading of arbitrary resource bundles when fallback is disabled Bug: http://bugs.php.net/54540 (Assigned) Allow loading of arbitrary resource bundles when fallback is disabled. Changed paths: U php/php-src/branches/PHP_5_3/NEWS U php/php-src/branches/PHP_5_3/ext/intl/resourcebundle/resourcebundle_class.c U php/php-src/branches/PHP_5_3/ext/intl/tests/resourcebundle_create.phpt A php/php-src/branches/PHP_5_3/ext/intl/tests/resourcebundle_internal.phpt U php/php-src/trunk/ext/intl/resourcebundle/resourcebundle_class.c U php/php-src/trunk/ext/intl/tests/resourcebundle_create.phpt A php/php-src/trunk/ext/intl/tests/resourcebundle_internal.phpt Modified: php/php-src/branches/PHP_5_3/NEWS =================================================================== --- php/php-src/branches/PHP_5_3/NEWS 2011-04-17 21:28:55 UTC (rev 310292) +++ php/php-src/branches/PHP_5_3/NEWS 2011-04-17 21:56:26 UTC (rev 310293) @@ -42,6 +42,10 @@ - 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) Modified: php/php-src/branches/PHP_5_3/ext/intl/resourcebundle/resourcebundle_class.c =================================================================== --- php/php-src/branches/PHP_5_3/ext/intl/resourcebundle/resourcebundle_class.c 2011-04-17 21:28:55 UTC (rev 310292) +++ php/php-src/branches/PHP_5_3/ext/intl/resourcebundle/resourcebundle_class.c 2011-04-17 21:56:26 UTC (rev 310293) @@ -102,7 +102,11 @@ 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"); Modified: php/php-src/branches/PHP_5_3/ext/intl/tests/resourcebundle_create.phpt =================================================================== --- php/php-src/branches/PHP_5_3/ext/intl/tests/resourcebundle_create.phpt 2011-04-17 21:28:55 UTC (rev 310292) +++ php/php-src/branches/PHP_5_3/ext/intl/tests/resourcebundle_create.phpt 2011-04-17 21:56:26 UTC (rev 310293) @@ -57,6 +57,6 @@ -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 Added: php/php-src/branches/PHP_5_3/ext/intl/tests/resourcebundle_internal.phpt =================================================================== --- php/php-src/branches/PHP_5_3/ext/intl/tests/resourcebundle_internal.phpt (rev 0) +++ php/php-src/branches/PHP_5_3/ext/intl/tests/resourcebundle_internal.phpt 2011-04-17 21:56:26 UTC (rev 310293) @@ -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) Modified: php/php-src/trunk/ext/intl/resourcebundle/resourcebundle_class.c =================================================================== --- php/php-src/trunk/ext/intl/resourcebundle/resourcebundle_class.c 2011-04-17 21:28:55 UTC (rev 310292) +++ php/php-src/trunk/ext/intl/resourcebundle/resourcebundle_class.c 2011-04-17 21:56:26 UTC (rev 310293) @@ -102,7 +102,11 @@ 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"); Modified: php/php-src/trunk/ext/intl/tests/resourcebundle_create.phpt =================================================================== --- php/php-src/trunk/ext/intl/tests/resourcebundle_create.phpt 2011-04-17 21:28:55 UTC (rev 310292) +++ php/php-src/trunk/ext/intl/tests/resourcebundle_create.phpt 2011-04-17 21:56:26 UTC (rev 310293) @@ -57,6 +57,6 @@ -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 Added: php/php-src/trunk/ext/intl/tests/resourcebundle_internal.phpt =================================================================== --- php/php-src/trunk/ext/intl/tests/resourcebundle_internal.phpt (rev 0) +++ php/php-src/trunk/ext/intl/tests/resourcebundle_internal.phpt 2011-04-17 21:56:26 UTC (rev 310293) @@ -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)
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
