[PATCH 3/6] Make it possible to translate strings containing subscript "2"

Lubomir I. Ivanov neolit123 at gmail.com
Sat Dec 22 13:34:21 PST 2012


From: "Lubomir I. Ivanov" <neolit123 at gmail.com>

The "Tec settings" dialog contains some strings with the
subscript "2" character, which have to be translated. While
the "2" is part of the string xgettext doesn't seem to recognize
such. To trick it we use a temporary buffer and c-format:

sprintf(utf8_buf, _("Show pO%s graph"), UTF8_SUBSCRIPT_2);
button = gtk_check_button_new_with_label(utf8_buf);

Signed-off-by: Lubomir I. Ivanov <neolit123 at gmail.com>
---
 gtk-gui.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/gtk-gui.c b/gtk-gui.c
index 634013a..74cee16 100644
--- a/gtk-gui.c
+++ b/gtk-gui.c
@@ -574,7 +574,7 @@ static void preferences_dialog(GtkWidget *w, gpointer data)
 	GtkWidget *dialog, *notebook, *font, *frame, *box, *vbox, *button, *xmlfile_button;
 	GtkWidget *entry_po2, *entry_pn2, *entry_phe;
 	const char *current_default, *new_default;
-	char threshold_text[10];
+	char threshold_text[10], utf8_buf[128];
 	struct preferences oldprefs = prefs;
 
 	dialog = gtk_dialog_new_with_buttons(_("Preferences"),
@@ -715,12 +715,14 @@ static void preferences_dialog(GtkWidget *w, gpointer data)
 	box = gtk_hbox_new(FALSE, 6);
 	gtk_container_add(GTK_CONTAINER(vbox), box);
 
-	button = gtk_check_button_new_with_label(_("Show pO" UTF8_SUBSCRIPT_2 " graph"));
+	sprintf(utf8_buf, _("Show pO%s graph"), UTF8_SUBSCRIPT_2);
+	button = gtk_check_button_new_with_label(utf8_buf);
 	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), prefs.pp_graphs.po2);
 	gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 6);
 	g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(po2_toggle), &entry_po2);
 
-	frame = gtk_frame_new(_("pO" UTF8_SUBSCRIPT_2 " threshold"));
+	sprintf(utf8_buf, _("pO%s threshold"), UTF8_SUBSCRIPT_2);
+	frame = gtk_frame_new(utf8_buf);
 	gtk_box_pack_start(GTK_BOX(box), frame, FALSE, FALSE, 6);
 	entry_po2 = gtk_entry_new();
 	gtk_entry_set_max_length(GTK_ENTRY(entry_po2), 4);
@@ -732,12 +734,14 @@ static void preferences_dialog(GtkWidget *w, gpointer data)
 	box = gtk_hbox_new(FALSE, 6);
 	gtk_container_add(GTK_CONTAINER(vbox), box);
 
-	button = gtk_check_button_new_with_label(_("Show pN" UTF8_SUBSCRIPT_2 " graph"));
+	sprintf(utf8_buf, _("Show pN%s graph"), UTF8_SUBSCRIPT_2);
+	button = gtk_check_button_new_with_label(utf8_buf);
 	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), prefs.pp_graphs.pn2);
 	gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 6);
 	g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(pn2_toggle), &entry_pn2);
 
-	frame = gtk_frame_new(_("pN" UTF8_SUBSCRIPT_2 " threshold"));
+	sprintf(utf8_buf, _("pN%s threshold"), UTF8_SUBSCRIPT_2);
+	frame = gtk_frame_new(utf8_buf);
 	gtk_box_pack_start(GTK_BOX(box), frame, FALSE, FALSE, 6);
 	entry_pn2 = gtk_entry_new();
 	gtk_entry_set_max_length(GTK_ENTRY(entry_pn2), 4);
-- 
1.7.11.msysgit.0



More information about the subsurface mailing list