Skip to content

Commit 07fcf5e

Browse files
committed
intl: Update grandfathered and redundant language tags
Closes GH-7641.
1 parent 0a3d551 commit 07fcf5e

File tree

3 files changed

+460
-25
lines changed

3 files changed

+460
-25
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ PHP NEWS
88
- Core:
99
. Fixed bug #81380 (Observer may not be initialized properly). (krakjoe)
1010

11+
- Intl:
12+
. Update all grandfathered language tags with preferred values
13+
1114
- OCI8:
1215
. Added oci8.prefetch_lob_size directive to tune LOB query performance
1316

ext/intl/locale/locale_methods.c

Lines changed: 119 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -55,31 +55,125 @@ ZEND_EXTERN_MODULE_GLOBALS( intl )
5555
#define EXTLANG_KEYNAME_LEN 10
5656
#define PRIVATE_KEYNAME_LEN 11
5757

58-
/* Based on IANA registry at the time of writing this code
59-
*
60-
*/
58+
/* Based on the IANA language subtag registry (File-Date: 2021-08-06)
59+
* https://www.iana.org/assignments/language-subtag-registry
60+
*
61+
* This list includes all grandfathered tags, as well as redundant
62+
* tags that have a Preferred-Value.
63+
*/
6164
static const char * const LOC_GRANDFATHERED[] = {
62-
"art-lojban", "i-klingon", "i-lux", "i-navajo", "no-bok", "no-nyn",
63-
"cel-gaulish", "en-GB-oed", "i-ami",
64-
"i-bnn", "i-default", "i-enochian",
65-
"i-mingo", "i-pwn", "i-tao",
66-
"i-tay", "i-tsu", "sgn-BE-fr",
67-
"sgn-BE-nl", "sgn-CH-de", "zh-cmn",
68-
"zh-cmn-Hans", "zh-cmn-Hant", "zh-gan" ,
69-
"zh-guoyu", "zh-hakka", "zh-min",
70-
"zh-min-nan", "zh-wuu", "zh-xiang",
71-
"zh-yue", NULL
65+
"art-lojban",
66+
"cel-gaulish",
67+
"en-GB-oed",
68+
"i-ami",
69+
"i-bnn",
70+
"i-default",
71+
"i-enochian",
72+
"i-hak",
73+
"i-klingon",
74+
"i-lux",
75+
"i-mingo",
76+
"i-navajo",
77+
"i-pwn",
78+
"i-tao",
79+
"i-tay",
80+
"i-tsu",
81+
"no-bok",
82+
"no-nyn",
83+
"sgn-BE-FR",
84+
"sgn-BE-NL",
85+
"sgn-BR",
86+
"sgn-CH-DE",
87+
"sgn-CO",
88+
"sgn-DE",
89+
"sgn-DK",
90+
"sgn-ES",
91+
"sgn-FR",
92+
"sgn-GB",
93+
"sgn-GR",
94+
"sgn-IE",
95+
"sgn-IT",
96+
"sgn-JP",
97+
"sgn-MX",
98+
"sgn-NI",
99+
"sgn-NL",
100+
"sgn-NO",
101+
"sgn-PT",
102+
"sgn-SE",
103+
"sgn-US",
104+
"sgn-ZA",
105+
"zh-cmn",
106+
"zh-cmn-Hans",
107+
"zh-cmn-Hant",
108+
"zh-gan",
109+
"zh-guoyu",
110+
"zh-hakka",
111+
"zh-min",
112+
"zh-min-nan",
113+
"zh-wuu",
114+
"zh-xiang",
115+
NULL
72116
};
73117

74-
/* Based on IANA registry at the time of writing this code
75-
* This array lists the preferred values for the grandfathered tags if applicable
76-
* This is in sync with the array LOC_GRANDFATHERED
77-
* e.g. the offsets of the grandfathered tags match the offset of the preferred value
78-
*/
79-
static const int LOC_PREFERRED_GRANDFATHERED_LEN = 6;
80-
static const char * const LOC_PREFERRED_GRANDFATHERED[] = {
81-
"jbo", "tlh", "lb",
82-
"nv", "nb", "nn",
118+
/* Based on the IANA language subtag registry (File-Date: 2021-08-06)
119+
*
120+
* This array lists the preferred values for the grandfathered and redundant
121+
* tags listed in LOC_GRANDFATHERED. This is in sync with the array
122+
* LOC_GRANDFATHERED, i.e., the offsets of the grandfathered tags match the
123+
* offsets of the preferred value. If a value in LOC_PREFERRED_GRANDFATHERED is
124+
* NULL, then the matching offset in LOC_GRANDFATHERED has no preferred value.
125+
*/
126+
static const char * const LOC_PREFERRED_GRANDFATHERED[] = {
127+
"jbo",
128+
NULL,
129+
"en-GB-oxendict",
130+
"ami",
131+
"bnn",
132+
NULL,
133+
NULL,
134+
"hak",
135+
"tlh",
136+
"lb",
137+
NULL,
138+
"nv",
139+
"pwn",
140+
"tao",
141+
"tay",
142+
"tsu",
143+
"nb",
144+
"nn",
145+
"sfb",
146+
"vgt",
147+
"bzs",
148+
"sgg",
149+
"csn",
150+
"gsg",
151+
"dsl",
152+
"ssp",
153+
"fsl",
154+
"bfi",
155+
"gss",
156+
"isg",
157+
"ise",
158+
"jsl",
159+
"mfs",
160+
"ncs",
161+
"dse",
162+
"nsl",
163+
"psr",
164+
"swl",
165+
"ase",
166+
"sfs",
167+
"cmn",
168+
"cmn-Hans",
169+
"cmn-Hant",
170+
"gan",
171+
"cmn",
172+
"hak",
173+
NULL,
174+
"nan",
175+
"wuu",
176+
"hsn",
83177
NULL
84178
};
85179

@@ -105,7 +199,7 @@ static int16_t findOffset(const char* const* list, const char* key)
105199
{
106200
const char* const* anchor = list;
107201
while (*list != NULL) {
108-
if (strcmp(key, *list) == 0) {
202+
if (strcasecmp(key, *list) == 0) {
109203
return (int16_t)(list - anchor);
110204
}
111205
list++;
@@ -125,7 +219,7 @@ static char* getPreferredTag(const char* gf_tag)
125219
if(grOffset < 0) {
126220
return NULL;
127221
}
128-
if( grOffset < LOC_PREFERRED_GRANDFATHERED_LEN ){
222+
if( LOC_PREFERRED_GRANDFATHERED[grOffset] != NULL ){
129223
/* return preferred tag */
130224
result = estrdup( LOC_PREFERRED_GRANDFATHERED[grOffset] );
131225
} else {
@@ -503,7 +597,7 @@ static void get_icu_disp_value_src_php( char* tag_name, INTERNAL_FUNCTION_PARAME
503597
if( strcmp(tag_name , LOC_LANG_TAG)==0 ){
504598
mod_loc_name = getPreferredTag( loc_name );
505599
} else {
506-
/* Since Grandfathered, no value, do nothing, retutn NULL */
600+
/* Since Grandfathered, no value, do nothing, return NULL */
507601
RETURN_FALSE;
508602
}
509603
}

0 commit comments

Comments
 (0)