summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/event_xml_parser.c73
-rw-r--r--src/plugins/Makefile.am14
-rw-r--r--src/plugins/analyze_LocalGDB.xml5
-rw-r--r--src/plugins/analyze_LocalGDB.xml.in5
-rw-r--r--src/plugins/analyze_RetraceServer.xml.in (renamed from src/plugins/analyze_RetraceServer.xml)6
-rw-r--r--src/plugins/report_Bugzilla.xml.in (renamed from src/plugins/report_Bugzilla.xml)20
-rw-r--r--src/plugins/report_Kerneloops.xml.in (renamed from src/plugins/report_Kerneloops.xml)8
-rw-r--r--src/plugins/report_Mailx.xml.in (renamed from src/plugins/report_Mailx.xml)20
-rw-r--r--src/plugins/report_RHTSupport.xml.in (renamed from src/plugins/report_RHTSupport.xml)20
9 files changed, 123 insertions, 48 deletions
diff --git a/src/lib/event_xml_parser.c b/src/lib/event_xml_parser.c
index a6aa9a1f..8bb89027 100644
--- a/src/lib/event_xml_parser.c
+++ b/src/lib/event_xml_parser.c
@@ -34,6 +34,9 @@ struct my_parse_data
event_option_t *cur_option;
};
+static char *elem_lang;
+static char *locale;
+
static const char *const option_types[] =
{
"text",
@@ -43,6 +46,39 @@ static const char *const option_types[] =
NULL
};
+static char * get_element_lang(const gchar **att_names, const gchar **att_values)
+{
+ char * short_locale_end = strchr(locale, '_');
+ VERB2 log("locale: %s", locale);
+ int i;
+ for (i = 0; att_names[i] != NULL; ++i)
+ {
+ VERB2 log("attr: %s:%s", att_names[i], att_values[i]);
+ if (strcmp(att_names[i], "xml:lang") == 0)
+ {
+ if (strcmp(att_values[i], locale) == 0)
+ {
+ VERB2 log("found translation for: %s", locale);
+ return xstrdup(att_values[i]);
+ }
+
+ /* try to match shorter locale
+ * e.g: "cs" with cs_CZ
+ */
+ if (strncmp(att_values[i], locale, short_locale_end-locale) == 0)
+ {
+ VERB2 log("found translation for shortlocale: %s", locale);
+ return xstrndup(att_values[i], short_locale_end-locale);
+ }
+ }
+ }
+ /* if the element has no attribute then it's a default non-localized value */
+ if (i == 0)
+ return xstrdup("C");
+ /* if the element is in different language then the current locale */
+ return NULL;
+}
+
static int cmp_event_option_name_with_string(gconstpointer a, gconstpointer b)
{
return strcmp(((event_option_t *)a)->name, (char *)b);
@@ -132,6 +168,15 @@ static void start_element(GMarkupParseContext *context,
}
}
}
+ else if (strcmp(element_name, LABEL_ELEMENT) == 0)
+ {
+ elem_lang = get_element_lang(attribute_names, attribute_values);
+ }
+ else if (strcmp(element_name, DESCRIPTION_ELEMENT) == 0)
+ {
+ elem_lang = get_element_lang(attribute_names, attribute_values);
+ }
+
}
// Called for close tags </foo>
@@ -142,6 +187,12 @@ static void end_element(GMarkupParseContext *context,
{
struct my_parse_data *parse_data = user_data;
+ if (elem_lang != NULL)
+ {
+ free(elem_lang);
+ elem_lang = NULL;
+ }
+
if (strcmp(element_name, OPTION_ELEMENT) == 0)
{
consume_cur_option(parse_data);
@@ -171,8 +222,16 @@ static void text(GMarkupParseContext *context,
if (strcmp(inner_element, LABEL_ELEMENT) == 0)
{
VERB2 log("new label:'%s'", text_copy);
- free(opt->label);
- opt->label = text_copy;
+ /* set the value only if we found a value for the current locale (elem_lang != "C")
+ * OR
+ * the label is still NULL and we found the default "C" value
+ */
+ if (elem_lang != NULL && ((strcmp(elem_lang, "C") != 0)
+ || (opt->label == NULL && (strcmp(elem_lang, "C") == 0))))
+ {
+ free(opt->label);
+ opt->label = text_copy;
+ }
return;
}
/*
@@ -227,8 +286,12 @@ static void text(GMarkupParseContext *context,
if (strcmp(inner_element, DESCRIPTION_ELEMENT) == 0)
{
VERB2 log("event description:'%s'", text_copy);
- free(ui->description);
- ui->description = text_copy;
+ if (elem_lang != NULL && ((strcmp(elem_lang, "C") != 0)
+ || (ui->description == NULL && (strcmp(elem_lang, "C") == 0))))
+ {
+ free(ui->description);
+ ui->description = text_copy;
+ }
return;
}
}
@@ -267,7 +330,7 @@ static void error(GMarkupParseContext *context,
void load_event_description_from_file(event_config_t *event_config, const char* filename)
{
struct my_parse_data parse_data = { event_config, NULL };
-
+ locale = setlocale(LC_ALL, "");
GMarkupParser parser;
memset(&parser, 0, sizeof(parser)); /* just in case */
parser.start_element = &start_element;
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index 74681884..418b5a19 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -42,6 +42,8 @@ dist_events_DATA = \
report_RHTSupport.xml \
report_Kerneloops.xml
+@INTLTOOL_XML_RULE@
+
eventsconfdir = $(EVENTS_CONF_DIR)
dist_eventsconf_DATA = \
@@ -59,7 +61,17 @@ man_MANS = \
PYTHON_FILES = abrt-action-install-debuginfo.py abrt-action-list-dsos.py
-EXTRA_DIST = $(man_MANS) $(PYTHON_FILES)
+EXTRA_DIST = \
+ $(man_MANS) \
+ $(PYTHON_FILES) \
+ report_Bugzilla.xml.in \
+ report_Bugzilla.conf \
+ report_Logger.conf \
+ analyze_LocalGDB.xml.in \
+ analyze_RetraceServer.xml.in \
+ report_Mailx.xml.in \
+ report_RHTSupport.xml.in \
+ report_Kerneloops.xml.in
$(DESTDIR)/$(DEBUG_INFO_DIR):
$(mkdir_p) '$@'
diff --git a/src/plugins/analyze_LocalGDB.xml b/src/plugins/analyze_LocalGDB.xml
deleted file mode 100644
index cf6064f2..00000000
--- a/src/plugins/analyze_LocalGDB.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<event>
- <name>Local GNU Debugger</name>
- <description>Download debuginfo packages and generate backtrace locally using GDB</description>
-</event>
diff --git a/src/plugins/analyze_LocalGDB.xml.in b/src/plugins/analyze_LocalGDB.xml.in
new file mode 100644
index 00000000..54209e70
--- /dev/null
+++ b/src/plugins/analyze_LocalGDB.xml.in
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<event>
+ <_name>Local GNU Debugger</_name>
+ <_description>Download debuginfo packages and generate backtrace locally using GDB</_description>
+</event>
diff --git a/src/plugins/analyze_RetraceServer.xml b/src/plugins/analyze_RetraceServer.xml.in
index ee5e225f..b3c7da24 100644
--- a/src/plugins/analyze_RetraceServer.xml
+++ b/src/plugins/analyze_RetraceServer.xml.in
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<event>
<name>Retrace Server</name>
- <description>Send core dump to remote retrace server for analysis</description>
+ <_description>Send core dump to remote retrace server for analysis</_description>
<options>
<option type="text" name="RETRACE_SERVER_URL">
- <label>Retrace server URL</label>
+ <_label>Retrace server URL</_label>
<default-value>retrace01.fedoraproject.org</default-value>
<allow-empty>no</allow-empty>
- <description>Address of the retrace server</description>
+ <_description>Address of the retrace server</_description>
</option>
</options>
</event>
diff --git a/src/plugins/report_Bugzilla.xml b/src/plugins/report_Bugzilla.xml.in
index 34a05447..6c87ad95 100644
--- a/src/plugins/report_Bugzilla.xml
+++ b/src/plugins/report_Bugzilla.xml.in
@@ -1,27 +1,27 @@
<?xml version="1.0" encoding="UTF-8" ?>
<event>
- <name>Bugzilla</name>
- <description>Report to Bugzilla bug tracker</description>
+ <_name>Bugzilla</_name>
+ <_description>Report to Bugzilla bug tracker</_description>
<options>
<option type="text" name="Bugzilla_BugzillaURL">
- <label>Bugzilla URL</label>
+ <_label>Bugzilla URL</_label>
<allow-empty>no</allow-empty>
- <description>Address of Bugzilla server</description>
+ <_description>Address of Bugzilla server</_description>
<default-value>https://bugzilla.redhat.com</default-value>
</option>
<option type="text" name="Bugzilla_Login">
- <label>User name</label>
+ <_label>User name</_label>
<allow-empty>no</allow-empty>
- <description>Bugzilla account user name</description>
+ <_description>Bugzilla account user name</_description>
</option>
<option type="password" name="Bugzilla_Password">
- <label>Password</label>
+ <_label>Password</_label>
<allow-empty>no</allow-empty>
- <description>Bugzilla account password</description>
+ <_description>Bugzilla account password</_description>
</option>
<option type="bool" name="Bugzilla_SSLVerify">
- <label>Verify SSL</label>
- <description>Check SSL key validity</description>
+ <_label>Verify SSL</_label>
+ <_description>Check SSL key validity</_description>
<default-value>yes</default-value>
</option>
</options>
diff --git a/src/plugins/report_Kerneloops.xml b/src/plugins/report_Kerneloops.xml.in
index bafe34d6..83ea50b5 100644
--- a/src/plugins/report_Kerneloops.xml
+++ b/src/plugins/report_Kerneloops.xml.in
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<event>
- <name>Kerneloops.org</name>
- <description>Send kernel problems to oops tracker</description>
+ <_name>Kerneloops.org</_name>
+ <_description>Send kernel problems to oops tracker</_description>
<options>
<option type="text" name="KerneloopsReporter_SubmitURL">
- <label>Kerneloops URL</label>
+ <_label>Kerneloops URL</_label>
<allow-empty>no</allow-empty>
- <description>Oops server url</description>
+ <_description>Oops server url</_description>
<default-value>http://submit.kerneloops.org/submitoops.php</default-value>
</option>
</options>
diff --git a/src/plugins/report_Mailx.xml b/src/plugins/report_Mailx.xml.in
index 6ef33d16..7584af7d 100644
--- a/src/plugins/report_Mailx.xml
+++ b/src/plugins/report_Mailx.xml.in
@@ -1,27 +1,27 @@
<?xml version="1.0" encoding="UTF-8" ?>
<event>
- <name>Mailx</name>
- <description>Send via email</description>
+ <_name>Mailx</_name>
+ <_description>Send via email</_description>
<options>
<option type="text" name="Mailx_Subject">
- <label>Subject</label>
+ <_label>Subject</_label>
<allow-empty>no</allow-empty>
- <description>Message subject</description>
+ <_description>Message subject</_description>
<default-value>[abrt] detected a crash</default-value>
</option>
<option type="text" name="Mailx_EmailFrom">
- <label>Sender</label>
+ <_label>Sender</_label>
<allow-empty>no</allow-empty>
- <description>Sender's email</description>
+ <_description>Sender's email</_description>
</option>
<option type="text" name="Mailx_EmailTo">
- <label>Recipient</label>
+ <_label>Recipient</_label>
<allow-empty>no</allow-empty>
- <description>Recipient's email</description>
+ <_description>Recipient's email</_description>
</option>
<option type="bool" name="Mailx_SendBinaryData">
- <label>Send Binary Data</label>
- <description>Send binary files like coredump</description>
+ <_label>Send Binary Data</_label>
+ <_description>Send binary files like coredump</_description>
<default-value>no</default-value>
</option>
</options>
diff --git a/src/plugins/report_RHTSupport.xml b/src/plugins/report_RHTSupport.xml.in
index 9dd0a734..725be3ac 100644
--- a/src/plugins/report_RHTSupport.xml
+++ b/src/plugins/report_RHTSupport.xml.in
@@ -1,27 +1,27 @@
<?xml version="1.0" encoding="UTF-8" ?>
<event>
- <name>Red Hat Customer Support</name>
- <description>Report to Red Hat support</description>
+ <_name>Red Hat Customer Support</_name>
+ <_description>Report to Red Hat support</_description>
<options>
<option type="text" name="RHTSupport_URL">
- <label>RH Portal URL</label>
+ <_label>RH Portal URL</_label>
<allow-empty>no</allow-empty>
- <description>Address of the Red Hat support portal</description>
+ <_description>Address of the Red Hat support portal</_description>
<default-value>https://api.access.redhat.com/rs</default-value>
</option>
<option type="text" name="RHTSupport_Login">
- <label>Username</label>
- <description>Red Hat customer user name</description>
+ <_label>Username</_label>
+ <_description>Red Hat customer user name</_description>
<allow-empty>no</allow-empty>
</option>
<option type="password" name="RHTSupport_Password">
- <label>Password</label>
- <description>Red Hat customer password</description>
+ <_label>Password</_label>
+ <_description>Red Hat customer password</_description>
<allow-empty>no</allow-empty>
</option>
<option type="bool" name="RHTSupport_SSLVerify">
- <label>Verify SSL</label>
- <description>Check SSL key validity</description>
+ <_label>Verify SSL</_label>
+ <_description>Check SSL key validity</_description>
<default-value>yes</default-value>
</option>
</options>