1--TEST-- 2locale_parse_locale() icu >= 4.8 3--SKIPIF-- 4<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> 5<?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0) print 'skip'; ?> 6--FILE-- 7<?php 8 9/* 10 * Try parsing different Locales 11 * with Procedural and Object methods. 12 */ 13 14function ut_main() 15{ 16 $res_str = ''; 17 18 $locales = array( 19 'uk-ua_CALIFORNIA@currency=;currency=GRN', 20 'root', 21 'uk@currency=EURO', 22 'Hindi', 23//Simple language subtag 24 'de', 25 'fr', 26 'ja', 27 'i-enochian', //(example of a grandfathered tag) 28//Language subtag plus Script subtag: 29 'zh-Hant', 30 'zh-Hans', 31 'sr-Cyrl', 32 'sr-Latn', 33//Language-Script-Region 34 'zh-Hans-CN', 35 'sr-Latn-CS', 36//Language-Variant 37 'sl-rozaj', 38 'sl-nedis', 39//Language-Region-Variant 40 'de-CH-1901', 41 'sl-IT-nedis', 42//Language-Script-Region-Variant 43 'sl-Latn-IT-nedis', 44//Language-Region: 45 'de-DE', 46 'en-US', 47 'es-419', 48//Private use subtags: 49 'de-CH-x-phonebk', 50 'az-Arab-x-AZE-derbend', 51//Extended language subtags 52 'zh-min', 53 'zh-min-nan-Hant-CN', 54//Private use registry values 55 'qaa-Qaaa-QM-x-southern', 56 'sr-Latn-QM', 57 'sr-Qaaa-CS', 58/*Tags that use extensions (examples ONLY: extensions MUST be defined 59 by revision or update to this document or by RFC): */ 60 'en-US-u-islamCal', 61 'zh-CN-a-myExt-x-private', 62 'en-a-myExt-b-another', 63//Some Invalid Tags: 64 'de-419-DE', 65 'a-DE', 66 'ar-a-aaa-b-bbb-a-ccc', 67 'x-AAAAAA', 68 ); 69 70 71 $res_str = ''; 72 73 foreach( $locales as $locale ) 74 { 75 $arr = ut_loc_locale_parse( $locale); 76 $res_str .= "---------------------\n"; 77 $res_str .= "$locale:\n"; 78 if( $arr){ 79 foreach( $arr as $key => $value){ 80 $res_str .= "$key : '$value' , "; 81 } 82 $res_str = rtrim($res_str); 83 } 84 else{ 85 $res_str .= "No values found from Locale parsing."; 86 } 87 $res_str .= "\n"; 88 } 89 90 $res_str .= "\n"; 91 return $res_str; 92 93} 94 95include_once( 'ut_common.inc' ); 96ut_run(); 97 98?> 99--EXPECTF-- 100--------------------- 101uk-ua_CALIFORNIA@currency=;currency=GRN: 102language : 'uk' , region : 'UA' , variant0 : 'CALIFORNIA' , 103--------------------- 104root: 105%s 106--------------------- 107uk@currency=EURO: 108language : 'uk' , 109--------------------- 110Hindi: 111language : 'hindi' , 112--------------------- 113de: 114language : 'de' , 115--------------------- 116fr: 117language : 'fr' , 118--------------------- 119ja: 120language : 'ja' , 121--------------------- 122i-enochian: 123grandfathered : 'i-enochian' , 124--------------------- 125zh-Hant: 126language : 'zh' , script : 'Hant' , 127--------------------- 128zh-Hans: 129language : 'zh' , script : 'Hans' , 130--------------------- 131sr-Cyrl: 132language : 'sr' , script : 'Cyrl' , 133--------------------- 134sr-Latn: 135language : 'sr' , script : 'Latn' , 136--------------------- 137zh-Hans-CN: 138language : 'zh' , script : 'Hans' , region : 'CN' , 139--------------------- 140sr-Latn-CS: 141language : 'sr' , script : 'Latn' , region : 'CS' , 142--------------------- 143sl-rozaj: 144language : 'sl' , variant0 : 'ROZAJ' , 145--------------------- 146sl-nedis: 147language : 'sl' , variant0 : 'NEDIS' , 148--------------------- 149de-CH-1901: 150language : 'de' , region : 'CH' , variant0 : '1901' , 151--------------------- 152sl-IT-nedis: 153language : 'sl' , region : 'IT' , variant0 : 'NEDIS' , 154--------------------- 155sl-Latn-IT-nedis: 156language : 'sl' , script : 'Latn' , region : 'IT' , variant0 : 'NEDIS' , 157--------------------- 158de-DE: 159language : 'de' , region : 'DE' , 160--------------------- 161en-US: 162language : 'en' , region : 'US' , 163--------------------- 164es-419: 165language : 'es' , region : '419' , 166--------------------- 167de-CH-x-phonebk: 168language : 'de' , region : 'CH' , private0 : 'phonebk' , 169--------------------- 170az-Arab-x-AZE-derbend: 171language : 'az' , script : 'Arab' , private0 : 'AZE' , private1 : 'derbend' , 172--------------------- 173zh-min: 174grandfathered : 'zh-min' , 175--------------------- 176zh-min-nan-Hant-CN: 177language : 'zh' , region : 'MIN' , variant0 : 'NAN' , variant1 : 'HANT' , variant2 : 'CN' , 178--------------------- 179qaa-Qaaa-QM-x-southern: 180language : 'qaa' , script : 'Qaaa' , region : 'QM' , private0 : 'southern' , 181--------------------- 182sr-Latn-QM: 183language : 'sr' , script : 'Latn' , region : 'QM' , 184--------------------- 185sr-Qaaa-CS: 186language : 'sr' , script : 'Qaaa' , region : 'CS' , 187--------------------- 188en-US-u-islamCal: 189language : 'en' , region : 'US' , 190--------------------- 191zh-CN-a-myExt-x-private: 192language : 'zh' , region : 'CN' , private0 : 'private' , 193--------------------- 194en-a-myExt-b-another: 195language : 'en' , 196--------------------- 197de-419-DE: 198language : 'de' , region : '419' , variant0 : 'DE' , 199--------------------- 200a-DE: 201No values found from Locale parsing. 202--------------------- 203ar-a-aaa-b-bbb-a-ccc: 204language : 'ar' , 205--------------------- 206x-AAAAAA: 207private0 : 'AAAAAA' , 208