-make gettext compatible

This commit is contained in:
Christian Grothoff 2021-08-04 18:34:25 +02:00
parent 6d099b44fb
commit 8a8cb1d2f9
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC

View File

@ -80,7 +80,9 @@ TALER_JSON_check_i18n (const json_t *i18n)
if (! json_is_string (member)) if (! json_is_string (member))
return false; return false;
/* Field name must be either of format "en_UK" /* Field name must be either of format "en_UK"
or just "en"; we do not care about capitalization */ or just "en"; we do not care about capitalization;
for syntax, see GNU Gettext manual, including
appendix A for rare language codes. */
switch (strlen (field)) switch (strlen (field))
{ {
case 0: case 0:
@ -107,6 +109,20 @@ TALER_JSON_check_i18n (const json_t *i18n)
if (! isalpha (field[4])) if (! isalpha (field[4]))
return false; return false;
break; break;
case 6:
if (! isalpha (field[0]))
return false;
if (! isalpha (field[1]))
return false;
if ('_' != field[2])
return false;
if (! isalpha (field[3]))
return false;
if (! isalpha (field[4]))
return false;
if (! isalpha (field[5]))
return false;
break;
default: default:
return false; return false;
} }