1--TEST--
2locale_parse_locale() icu <= 4.2
3--SKIPIF--
4<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5<?php if(version_compare(INTL_ICU_VERSION, '4.3', '<') != 1) 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    );
68
69
70    $res_str = '';
71
72    foreach( $locales as $locale )
73    {
74        $arr = ut_loc_locale_parse( $locale);
75        $res_str .= "---------------------\n";
76        $res_str .= "$locale:\n";
77        if( $arr){
78            foreach( $arr as $key => $value){
79                    $res_str .= "$key : '$value' , ";
80            }
81            $res_str = rtrim($res_str);
82        }
83        else{
84            $res_str .= "No values found from Locale parsing.";
85        }
86        $res_str .= "\n";
87    }
88
89    $res_str .= "\n";
90    return $res_str;
91
92}
93
94include_once( 'ut_common.inc' );
95ut_run();
96
97?>
98--EXPECTF--
99---------------------
100uk-ua_CALIFORNIA@currency=;currency=GRN:
101language : 'uk' , region : 'UA' , variant0 : 'CALIFORNIA' ,
102---------------------
103root:
104language : 'root' ,
105---------------------
106uk@currency=EURO:
107language : 'uk' ,
108---------------------
109Hindi:
110language : 'hindi' ,
111---------------------
112de:
113language : 'de' ,
114---------------------
115fr:
116language : 'fr' ,
117---------------------
118ja:
119language : 'ja' ,
120---------------------
121i-enochian:
122grandfathered : 'i-enochian' ,
123---------------------
124zh-Hant:
125language : 'zh' , script : 'Hant' ,
126---------------------
127zh-Hans:
128language : 'zh' , script : 'Hans' ,
129---------------------
130sr-Cyrl:
131language : 'sr' , script : 'Cyrl' ,
132---------------------
133sr-Latn:
134language : 'sr' , script : 'Latn' ,
135---------------------
136zh-Hans-CN:
137language : 'zh' , script : 'Hans' , region : 'CN' ,
138---------------------
139sr-Latn-CS:
140language : 'sr' , script : 'Latn' , region : 'CS' ,
141---------------------
142sl-rozaj:
143language : 'sl' ,%r( region : 'ROZAJ' ,)?%r
144---------------------
145sl-nedis:
146language : 'sl' ,%r( region : 'NEDIS' ,)?%r
147---------------------
148de-CH-1901:
149language : 'de' , region : 'CH' , variant0 : '1901' ,
150---------------------
151sl-IT-nedis:
152language : 'sl' , region : 'IT' , variant0 : 'NEDIS' ,
153---------------------
154sl-Latn-IT-nedis:
155language : 'sl' , script : 'Latn' , region : 'IT' , variant0 : 'NEDIS' ,
156---------------------
157de-DE:
158language : 'de' , region : 'DE' ,
159---------------------
160en-US:
161language : 'en' , region : 'US' ,
162---------------------
163es-419:
164language : 'es' , region : '419' ,
165---------------------
166de-CH-x-phonebk:
167language : 'de' , region : 'CH' , private0 : 'phonebk' ,
168---------------------
169az-Arab-x-AZE-derbend:
170language : 'az' , script : 'Arab' , private0 : 'AZE' , private1 : 'derbend' ,
171---------------------
172zh-min:
173grandfathered : 'zh-min' ,
174---------------------
175zh-min-nan-Hant-CN:
176language : 'zh' , region : 'MIN' , variant0 : 'NAN' , variant1 : 'HANT' , variant2 : 'CN' ,
177---------------------
178qaa-Qaaa-QM-x-southern:
179language : 'qaa' , script : 'Qaaa' , region : 'QM' , private0 : 'southern' ,
180---------------------
181sr-Latn-QM:
182language : 'sr' , script : 'Latn' , region : 'QM' ,
183---------------------
184sr-Qaaa-CS:
185language : 'sr' , script : 'Qaaa' , region : 'CS' ,
186---------------------
187en-US-u-islamCal:
188language : 'en' , region : 'US' ,
189---------------------
190zh-CN-a-myExt-x-private:
191language : 'zh' , region : 'CN' , private0 : 'private' ,
192---------------------
193en-a-myExt-b-another:
194language : 'en' ,
195---------------------
196de-419-DE:
197language : 'de' , region : '419' , variant0 : 'DE' ,
198---------------------
199a-DE:
200No values found from Locale parsing.
201---------------------
202ar-a-aaa-b-bbb-a-ccc:
203language : 'ar' ,
204