1--TEST--
2locale_get_region()
3--SKIPIF--
4<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5--FILE--
6<?php
7
8/*
9 * Try getting the region for 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        'x-whatever',
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        $scr = ut_loc_get_region( $locale);
75        $res_str .= "$locale:  region='$scr'";
76        $res_str .= "\n";
77    }
78
79    return $res_str;
80
81}
82
83include_once( 'ut_common.inc' );
84ut_run();
85
86?>
87--EXPECTF--
88uk-ua_CALIFORNIA@currency=;currency=GRN:  region='UA'
89root:  region=''
90uk@currency=EURO:  region=''
91Hindi:  region=''
92de:  region=''
93fr:  region=''
94ja:  region=''
95i-enochian:  region=''
96zh-Hant:  region=''
97zh-Hans:  region=''
98sr-Cyrl:  region=''
99sr-Latn:  region=''
100zh-Hans-CN:  region='CN'
101sr-Latn-CS:  region='CS'
102sl-rozaj:  region='%r(ROZAJ)?%r'
103sl-nedis:  region='%r(NEDIS)?%r'
104de-CH-1901:  region='CH'
105sl-IT-nedis:  region='IT'
106sl-Latn-IT-nedis:  region='IT'
107de-DE:  region='DE'
108en-US:  region='US'
109es-419:  region='419'
110de-CH-x-phonebk:  region='CH'
111az-Arab-x-AZE-derbend:  region='%r(X)?%r'
112zh-min:  region=''
113zh-min-nan-Hant-CN:  region='MIN'
114x-whatever:  region=''
115qaa-Qaaa-QM-x-southern:  region='QM'
116sr-Latn-QM:  region='QM'
117sr-Qaaa-CS:  region='CS'
118en-US-u-islamCal:  region='US'
119zh-CN-a-myExt-x-private:  region='CN'
120en-a-myExt-b-another:  region='%r(A)?%r'
121de-419-DE:  region='419'
122a-DE:  region='DE'
123ar-a-aaa-b-bbb-a-ccc:  region='%r(A)?%r'
124