From 79d82223a23527721dcc72cf973e1c3075eb1a20 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 10 Jun 2005 06:41:04 +0000 Subject: [PATCH] Generate N_() calls for translatable key names. 2005-06-10 Matthias Clasen * gdk/gen-keyname-table.pl: Generate N_() calls for translatable key names. * gdk/keynames.txt: Mark some key names as translatable. * gdk/keyname-table.h: Regenerated. * gtk/gtkaccellabel.c (gtk_accel_label_class_init): Add some context to the msg ids for keyboard modifiers and key names. (_gtk_accel_label_class_get_accelerator_label): Try to translate key names. (#300224, Christian Rose) --- ChangeLog | 15 +++++++++ ChangeLog.pre-2-10 | 15 +++++++++ ChangeLog.pre-2-8 | 15 +++++++++ gdk/gen-keyname-table.pl | 26 ++++++++++++++-- gdk/keyname-table.h | 44 +++++++++++++++++++++++++-- gdk/keynames.txt | 66 ++++++++++++++++++++-------------------- gtk/gtkaccellabel.c | 34 +++++++++++++++------ po/ChangeLog | 4 +++ po/POTFILES.in | 1 + 9 files changed, 172 insertions(+), 48 deletions(-) diff --git a/ChangeLog b/ChangeLog index ee73f1e880..65786e3586 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2005-06-10 Matthias Clasen + + * gdk/gen-keyname-table.pl: Generate N_() calls for + translatable key names. + + * gdk/keynames.txt: Mark some key names as translatable. + + * gdk/keyname-table.h: Regenerated. + + * gtk/gtkaccellabel.c (gtk_accel_label_class_init): Add + some context to the msg ids for keyboard modifiers and + key names. + (_gtk_accel_label_class_get_accelerator_label): Try to + translate key names. (#300224, Christian Rose) + 2005-06-10 Federico Mena Quintero Merged from gtk-2-6: diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index ee73f1e880..65786e3586 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,18 @@ +2005-06-10 Matthias Clasen + + * gdk/gen-keyname-table.pl: Generate N_() calls for + translatable key names. + + * gdk/keynames.txt: Mark some key names as translatable. + + * gdk/keyname-table.h: Regenerated. + + * gtk/gtkaccellabel.c (gtk_accel_label_class_init): Add + some context to the msg ids for keyboard modifiers and + key names. + (_gtk_accel_label_class_get_accelerator_label): Try to + translate key names. (#300224, Christian Rose) + 2005-06-10 Federico Mena Quintero Merged from gtk-2-6: diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index ee73f1e880..65786e3586 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,18 @@ +2005-06-10 Matthias Clasen + + * gdk/gen-keyname-table.pl: Generate N_() calls for + translatable key names. + + * gdk/keynames.txt: Mark some key names as translatable. + + * gdk/keyname-table.h: Regenerated. + + * gtk/gtkaccellabel.c (gtk_accel_label_class_init): Add + some context to the msg ids for keyboard modifiers and + key names. + (_gtk_accel_label_class_get_accelerator_label): Try to + translate key names. (#300224, Christian Rose) + 2005-06-10 Federico Mena Quintero Merged from gtk-2-6: diff --git a/gdk/gen-keyname-table.pl b/gdk/gen-keyname-table.pl index 9a85f3af7c..e0fe9642b2 100755 --- a/gdk/gen-keyname-table.pl +++ b/gdk/gen-keyname-table.pl @@ -7,13 +7,18 @@ if (@ARGV != 1) { open IN, $ARGV[0] || die "Cannot open $ARGV[0]: $!\n"; @keys = (); +@translate = (); while (defined($_ = )) { next if /^!/; - if (!/^\s*(0x[0-9a-f]+)\s+(.*\S)\s+$/) { + if (!/^\s*(0x[0-9a-f]+)\s+([\w_]*\S)\s+(1)?\s*$/) { die "Cannot parse line $_"; } push @keys, [$1, $2]; + + if (defined ($3)) { + push @translate, $2; + } } $offset = 0; @@ -88,5 +93,22 @@ for $key (@keys) { $i++; } -print "\n};\n"; +print <mod_name_shift = g_strdup (_("Shift")); + class->mod_name_shift = g_strdup (Q_("keyboard label|Shift")); /* This is the text that should appear next to menu accelerators * that use the control key. If the text on this key isn't typically * translated on keyboards used for your language, don't translate * this. + * And do not translate the part before the |. */ - class->mod_name_control = g_strdup (_("Ctrl")); + class->mod_name_control = g_strdup (Q_("keyboard label|Ctrl")); /* This is the text that should appear next to menu accelerators * that use the alt key. If the text on this key isn't typically * translated on keyboards used for your language, don't translate * this. + * And do not translate the part before the |. */ - class->mod_name_alt = g_strdup (_("Alt")); + class->mod_name_alt = g_strdup (Q_("keyboard label|Alt")); class->mod_separator = g_strdup ("+"); class->accel_seperator = g_strdup (" / "); class->latin1_to_char = TRUE; @@ -570,10 +573,12 @@ _gtk_accel_label_class_get_accelerator_label (GtkAccelLabelClass *klass, switch (ch) { case ' ': - g_string_append (gstring, "Space"); + /* do not translate the part before the | */ + g_string_append (gstring, Q_("keyboard label|Space")); break; case '\\': - g_string_append (gstring, "Backslash"); + /* do not translate the part before the | */ + g_string_append (gstring, Q_("keyboard label|Backslash")); break; default: g_string_append_unichar (gstring, g_unichar_toupper (ch)); @@ -583,13 +588,22 @@ _gtk_accel_label_class_get_accelerator_label (GtkAccelLabelClass *klass, else { gchar *tmp; - - tmp = gtk_accelerator_name (accelerator_key, 0); - if (tmp[0] != 0 && tmp[1] == 0) + + tmp = gdk_keyval_name (gdk_keyval_to_lower (accelerator_key)); + if (tmp == NULL) + tmp = ""; + else if (tmp[0] != 0 && tmp[1] == 0) tmp[0] = g_ascii_toupper (tmp[0]); - substitute_underscores (tmp); + else + { + gchar msg[128]; + + strcpy (msg, "keyboard label|"); + g_strlcat (msg, tmp, 128); + tmp = g_strip_context (msg, dgettext (GETTEXT_PACKAGE, msg)); + substitute_underscores (tmp); + } g_string_append (gstring, tmp); - g_free (tmp); } return g_string_free (gstring, FALSE); diff --git a/po/ChangeLog b/po/ChangeLog index 3a165b36f4..e8ac8964e7 100644 --- a/po/ChangeLog +++ b/po/ChangeLog @@ -1,3 +1,7 @@ +2005-06-10 Matthias Clasen + + * POTFILES.in: Add gdk/keyname-table.h + 2005-06-08 Priit Laes * et.po: Translation updated by Ivar Smolin. diff --git a/po/POTFILES.in b/po/POTFILES.in index df2ee2ae6b..c6e597cbee 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -23,6 +23,7 @@ gdk-pixbuf/io-xpm.c gdk/gdk.c gdk/gdkdisplaymanager.c gdk/gdkpango.c +gdk/keyname-table.h gdk/win32/gdkmain-win32.c gdk/x11/gdkmain-x11.c gtk/gtkaboutdialog.c