1--TEST--
2locale_lookup.phpt()
3--SKIPIF--
4<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5<?php if (version_compare(INTL_ICU_VERSION, '67.1') < 0) die('skip for ICU >= 67.1'); ?>
6--FILE--
7<?php
8
9/*
10 * Try parsing different Locales
11 * with Procedural and Object methods.
12 */
13
14function ut_main()
15{
16    $loc_ranges = array(
17        'de-de',
18        'sl_IT',
19        'sl_IT_Nedis',
20        'jbo',
21        'art-lojban'
22    );
23
24    $lang_tags = array(
25        'de-DEVA',
26        'de-DE-1996',
27        'de-DE',
28        'zh_Hans',
29        'de-CH-1996',
30        'sl_IT',
31        'sl_IT_nedis-a-kirti-x-xyz',
32        'sl_IT_rozaj',
33        'sl_IT_NEDIS_ROJAZ_1901',
34        'i-enochian',
35        'sgn-CH-de',
36        'art-lojban',
37        'i-lux',
38        'art-lojban',
39        'jbo',
40        'en_sl_IT',
41        'zh-Hant-CN-x-prv1-prv2'
42    );
43
44
45    $res_str = '';
46    $isCanonical = false;
47
48    foreach($loc_ranges as $loc_range){
49            $res_str .="--------------\n";
50            $result= ut_loc_locale_lookup( $lang_tags , $loc_range,$isCanonical,"en_US");
51            $comma_arr =implode(",",$lang_tags);
52            $res_str .= "loc_range:$loc_range \nlang_tags: $comma_arr\n";
53            $res_str .= "\nlookup result:$result\n";
54//canonicalized version
55            $result= ut_loc_locale_lookup( $lang_tags , $loc_range,!($isCanonical),"en_US");
56            $can_loc_range = ut_loc_canonicalize($loc_range);
57            $res_str .= "Canonical lookup result:$result\n";
58
59    }
60
61    $res_str .= "\n";
62    return $res_str;
63
64}
65
66include_once( 'ut_common.inc' );
67ut_run();
68
69?>
70--EXPECT--
71--------------
72loc_range:de-de
73lang_tags: de-DEVA,de-DE-1996,de-DE,zh_Hans,de-CH-1996,sl_IT,sl_IT_nedis-a-kirti-x-xyz,sl_IT_rozaj,sl_IT_NEDIS_ROJAZ_1901,i-enochian,sgn-CH-de,art-lojban,i-lux,art-lojban,jbo,en_sl_IT,zh-Hant-CN-x-prv1-prv2
74
75lookup result:de-DE
76Canonical lookup result:de_de
77--------------
78loc_range:sl_IT
79lang_tags: de-DEVA,de-DE-1996,de-DE,zh_Hans,de-CH-1996,sl_IT,sl_IT_nedis-a-kirti-x-xyz,sl_IT_rozaj,sl_IT_NEDIS_ROJAZ_1901,i-enochian,sgn-CH-de,art-lojban,i-lux,art-lojban,jbo,en_sl_IT,zh-Hant-CN-x-prv1-prv2
80
81lookup result:sl_IT
82Canonical lookup result:sl_it
83--------------
84loc_range:sl_IT_Nedis
85lang_tags: de-DEVA,de-DE-1996,de-DE,zh_Hans,de-CH-1996,sl_IT,sl_IT_nedis-a-kirti-x-xyz,sl_IT_rozaj,sl_IT_NEDIS_ROJAZ_1901,i-enochian,sgn-CH-de,art-lojban,i-lux,art-lojban,jbo,en_sl_IT,zh-Hant-CN-x-prv1-prv2
86
87lookup result:sl_IT
88Canonical lookup result:sl_it
89--------------
90loc_range:jbo
91lang_tags: de-DEVA,de-DE-1996,de-DE,zh_Hans,de-CH-1996,sl_IT,sl_IT_nedis-a-kirti-x-xyz,sl_IT_rozaj,sl_IT_NEDIS_ROJAZ_1901,i-enochian,sgn-CH-de,art-lojban,i-lux,art-lojban,jbo,en_sl_IT,zh-Hant-CN-x-prv1-prv2
92
93lookup result:jbo
94Canonical lookup result:jbo
95--------------
96loc_range:art-lojban
97lang_tags: de-DEVA,de-DE-1996,de-DE,zh_Hans,de-CH-1996,sl_IT,sl_IT_nedis-a-kirti-x-xyz,sl_IT_rozaj,sl_IT_NEDIS_ROJAZ_1901,i-enochian,sgn-CH-de,art-lojban,i-lux,art-lojban,jbo,en_sl_IT,zh-Hant-CN-x-prv1-prv2
98
99lookup result:art-lojban
100Canonical lookup result:jbo
101