[gnome-control-center] keyboard: Add support for msgctxt in keybindings
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] keyboard: Add support for msgctxt in keybindings
- Date: Thu, 6 Dec 2012 09:09:01 +0000 (UTC)
commit f94aeb2b023c224d0d8397a53d2fbf5f9f3062f1
Author: Bastien Nocera <hadess hadess net>
Date: Thu Dec 6 10:04:55 2012 +0100
keyboard: Add support for msgctxt in keybindings
Unfortunately, this means duplicating the description attribute
to the text inside the KeyListEntry element, and marking the
KeyListEntry element as translatable by prepending "_".
<KeyListEntry
name="search"
_description="Search"/>
becomes:
<_KeyListEntry
name="search"
description="Search"
msgctxt="keybinding">
Search
</_KeyListEntry>
https://bugzilla.gnome.org/show_bug.cgi?id=689623
panels/keyboard/keyboard-shortcuts.c | 27 +++++++++++++++------------
1 files changed, 15 insertions(+), 12 deletions(-)
---
diff --git a/panels/keyboard/keyboard-shortcuts.c b/panels/keyboard/keyboard-shortcuts.c
index 967251e..f034da7 100644
--- a/panels/keyboard/keyboard-shortcuts.c
+++ b/panels/keyboard/keyboard-shortcuts.c
@@ -309,11 +309,12 @@ parse_start_tag (GMarkupParseContext *ctx,
{
KeyList *keylist = (KeyList *) user_data;
KeyListEntry key;
- const char *name, *schema, *description, *package;
+ const char *name, *schema, *description, *package, *context, *orig_description;
name = NULL;
schema = NULL;
package = NULL;
+ context = NULL;
/* The top-level element, names the section in the tree */
if (g_str_equal (element_name, "KeyListEntries"))
@@ -390,6 +391,8 @@ parse_start_tag (GMarkupParseContext *ctx,
schema = NULL;
description = NULL;
+ context = NULL;
+ orig_description = NULL;
while (*attr_names && *attr_values)
{
@@ -403,17 +406,12 @@ parse_start_tag (GMarkupParseContext *ctx,
schema = *attr_values;
}
} else if (g_str_equal (*attr_names, "description")) {
- if (**attr_values) {
- if (keylist->package)
- {
- description = dgettext (keylist->package, *attr_values);
- }
- else
- {
- description = _(*attr_values);
- }
- }
- }
+ if (**attr_values)
+ orig_description = *attr_values;
+ } else if (g_str_equal (*attr_names, "msgctxt")) {
+ if (**attr_values)
+ context = *attr_values;
+ }
++attr_names;
++attr_values;
@@ -428,6 +426,11 @@ parse_start_tag (GMarkupParseContext *ctx,
return;
}
+ if (context != NULL)
+ description = g_dpgettext2 (keylist->package, context, orig_description);
+ else
+ description = dgettext (keylist->package, orig_description);
+
key.name = g_strdup (name);
key.type = CC_KEYBOARD_ITEM_TYPE_GSETTINGS;
key.description = replace_pictures_folder (description);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]