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