1--TEST--
2locale_parse_locale() icu >= 4.8
3--EXTENSIONS--
4intl
5--FILE--
6<?php
7
8/*
9 * Try parsing different Locales
10 * with Procedural and Object methods.
11 */
12
13function ut_main()
14{
15    $res_str = '';
16
17    $locales = array(
18        'uk-ua_CALIFORNIA@currency=;currency=GRN',
19        'root',
20        'uk@currency=EURO',
21        'Hindi',
22//Simple language subtag
23        'de',
24        'fr',
25        'ja',
26        'i-enochian', //(example of a grandfathered tag)
27//Language subtag plus Script subtag:
28        'zh-Hant',
29        'zh-Hans',
30        'sr-Cyrl',
31        'sr-Latn',
32//Language-Script-Region
33        'zh-Hans-CN',
34        'sr-Latn-CS',
35//Language-Variant
36        'sl-rozaj',
37        'sl-nedis',
38//Language-Region-Variant
39        'de-CH-1901',
40        'sl-IT-nedis',
41//Language-Script-Region-Variant
42        'sl-Latn-IT-nedis',
43//Language-Region:
44        'de-DE',
45        'en-US',
46        'es-419',
47//Private use subtags:
48        'de-CH-x-phonebk',
49        'az-Arab-x-AZE-derbend',
50//Extended language subtags
51        'zh-min',
52        'zh-min-nan-Hant-CN',
53//Private use registry values
54        'qaa-Qaaa-QM-x-southern',
55        'sr-Latn-QM',
56        'sr-Qaaa-CS',
57/*Tags that use extensions (examples ONLY: extensions MUST be defined
58   by revision or update to this document or by RFC): */
59        'en-US-u-islamCal',
60        'zh-CN-a-myExt-x-private',
61        'en-a-myExt-b-another',
62//Some Invalid Tags:
63        'de-419-DE',
64        'a-DE',
65        'ar-a-aaa-b-bbb-a-ccc',
66    'x-AAAAAA',
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:
104%s
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' , variant0 : 'ROZAJ' ,
144---------------------
145sl-nedis:
146language : 'sl' , variant0 : 'NEDIS' ,
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---------------------
205x-AAAAAA:
206private0 : 'AAAAAA' ,
207