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