|
|
27390d |
From 09da182cd50ee9df08a20180d5fd1d136dc794d3 Mon Sep 17 00:00:00 2001
|
|
|
27390d |
From: Jakub Filak <jfilak@redhat.com>
|
|
|
27390d |
Date: Sat, 8 Feb 2014 09:15:35 +0100
|
|
|
27390d |
Subject: [LIBREPORT PATCH 22/24] localization: properly handle locales with
|
|
|
27390d |
encoding suffix
|
|
|
27390d |
|
|
|
27390d |
XML nodes contain xml:lang attributes whose values are plain language
|
|
|
27390d |
codes (en_GB, zh_CN, ...).
|
|
|
27390d |
|
|
|
27390d |
libreport tries to find exact match with cur locale which may be
|
|
|
27390d |
suffixed with char set identifier (.UTF-8). Therefore libreport never
|
|
|
27390d |
finds exact match.
|
|
|
27390d |
|
|
|
27390d |
This patch removes the encoding suffix from cur locale string.
|
|
|
27390d |
|
|
|
27390d |
Closes to rhbz#1063320
|
|
|
27390d |
|
|
|
27390d |
Signed-off-by: Jakub Filak <jfilak@redhat.com>
|
|
|
27390d |
---
|
|
|
27390d |
src/include/xml_parser.h | 2 +-
|
|
|
27390d |
src/lib/event_xml_parser.c | 6 ++++--
|
|
|
27390d |
src/lib/workflow_xml_parser.c | 4 +++-
|
|
|
27390d |
3 files changed, 8 insertions(+), 4 deletions(-)
|
|
|
27390d |
|
|
|
27390d |
diff --git a/src/include/xml_parser.h b/src/include/xml_parser.h
|
|
|
27390d |
index 59517b3..36fd2ae 100644
|
|
|
27390d |
--- a/src/include/xml_parser.h
|
|
|
27390d |
+++ b/src/include/xml_parser.h
|
|
|
27390d |
@@ -22,7 +22,7 @@
|
|
|
27390d |
struct my_parse_data
|
|
|
27390d |
{
|
|
|
27390d |
workflow_t *workflow;
|
|
|
27390d |
- const char *cur_locale;
|
|
|
27390d |
+ char *cur_locale;
|
|
|
27390d |
char *attribute_lang;
|
|
|
27390d |
bool in_event_list;
|
|
|
27390d |
bool exact_name;
|
|
|
27390d |
diff --git a/src/lib/event_xml_parser.c b/src/lib/event_xml_parser.c
|
|
|
27390d |
index 2a6f477..1f98158 100644
|
|
|
27390d |
--- a/src/lib/event_xml_parser.c
|
|
|
27390d |
+++ b/src/lib/event_xml_parser.c
|
|
|
27390d |
@@ -60,7 +60,7 @@ struct my_parse_data
|
|
|
27390d |
{
|
|
|
27390d |
parsed_event_config_t event_config;
|
|
|
27390d |
parsed_event_option_t cur_option;
|
|
|
27390d |
- const char *cur_locale;
|
|
|
27390d |
+ char *cur_locale;
|
|
|
27390d |
char *attribute_lang;
|
|
|
27390d |
bool in_adv_option;
|
|
|
27390d |
};
|
|
|
27390d |
@@ -511,7 +511,8 @@ void load_event_description_from_file(event_config_t *event_config, const char*
|
|
|
27390d |
{
|
|
|
27390d |
log_notice("loading event: '%s'", filename);
|
|
|
27390d |
struct my_parse_data parse_data = { {event_config, false, false, false}, {NULL, false, false}, NULL, NULL };
|
|
|
27390d |
- parse_data.cur_locale = setlocale(LC_ALL, NULL);
|
|
|
27390d |
+ parse_data.cur_locale = xstrdup(setlocale(LC_ALL, NULL));
|
|
|
27390d |
+ strchrnul(parse_data.cur_locale, '.')[0] = '\0';
|
|
|
27390d |
|
|
|
27390d |
GMarkupParser parser;
|
|
|
27390d |
memset(&parser, 0, sizeof(parser)); /* just in case */
|
|
|
27390d |
@@ -541,4 +542,5 @@ void load_event_description_from_file(event_config_t *event_config, const char*
|
|
|
27390d |
|
|
|
27390d |
consume_cur_option(&parse_data); /* just in case */
|
|
|
27390d |
free(parse_data.attribute_lang); /* just in case */
|
|
|
27390d |
+ free(parse_data.cur_locale);
|
|
|
27390d |
}
|
|
|
27390d |
diff --git a/src/lib/workflow_xml_parser.c b/src/lib/workflow_xml_parser.c
|
|
|
27390d |
index 681b171..0efc733 100644
|
|
|
27390d |
--- a/src/lib/workflow_xml_parser.c
|
|
|
27390d |
+++ b/src/lib/workflow_xml_parser.c
|
|
|
27390d |
@@ -165,7 +165,8 @@ void load_workflow_description_from_file(workflow_t *workflow, const char* filen
|
|
|
27390d |
{
|
|
|
27390d |
log_notice("loading workflow: '%s'", filename);
|
|
|
27390d |
struct my_parse_data parse_data = { workflow, NULL, NULL, 0, 0, 0};
|
|
|
27390d |
- parse_data.cur_locale = setlocale(LC_ALL, NULL);
|
|
|
27390d |
+ parse_data.cur_locale = xstrdup(setlocale(LC_ALL, NULL));
|
|
|
27390d |
+ strchrnul(parse_data.cur_locale, '.')[0] = '\0';
|
|
|
27390d |
|
|
|
27390d |
GMarkupParser parser;
|
|
|
27390d |
memset(&parser, 0, sizeof(parser)); /* just in case */
|
|
|
27390d |
@@ -194,4 +195,5 @@ void load_workflow_description_from_file(workflow_t *workflow, const char* filen
|
|
|
27390d |
g_markup_parse_context_free(context);
|
|
|
27390d |
|
|
|
27390d |
free(parse_data.attribute_lang); /* just in case */
|
|
|
27390d |
+ free(parse_data.cur_locale);
|
|
|
27390d |
}
|
|
|
27390d |
--
|
|
|
27390d |
1.8.3.1
|
|
|
27390d |
|