Permalink
Browse files

Replace '_' to '-' in lt_tag_transform()

likelySubtags.xml contains '_', which isn't impossible to match the tags
in lt_tag_t. this usually means lt_tag_transform() doesn't work without
this fix.

After this fix, following code just works:

lt_tag_t *tag;
char *s;

lt_tag_parse(tag, "zh-TW", NULL);
s = lt_tag_transform(tag, NULL));
printf("%s\n", s);
free(s);
--
zh-Hant-TW
  • Loading branch information...
1 parent 6af8dd1 commit 205d8e0af3d939350d5fb8d69bc5557be8f938de @tagoh committed Dec 3, 2012
Showing with 1 addition and 1 deletion.
  1. +1 −1 liblangtag/lt-tag.c
View
@@ -2061,7 +2061,7 @@ lt_tag_transform(lt_tag_t *tag,
"Unable to create an instance of xmlXPathContextPtr.");
goto bail;
}
- xpath_string = lt_strdup_printf("/supplementalData/likelySubtags/likelySubtag[@from = '%s']", tag_string);
+ xpath_string = lt_strdup_printf("/supplementalData/likelySubtags/likelySubtag[translate(@from,'_', '-') = '%s']", tag_string);
xobj = xmlXPathEvalExpression((const xmlChar *)xpath_string, xctxt);
if (!xobj) {
lt_error_set(&err, LT_ERR_FAIL_ON_XML,

0 comments on commit 205d8e0

Please sign in to comment.