[gnome-keyring] gcr: GcrColumn.label should be translated with context.



commit adc1e51a0dba25e2f4f74f62f02b6d20ae762448
Author: Stef Walter <stefw collabora co uk>
Date:   Tue Apr 19 09:52:19 2011 +0200

    gcr: GcrColumn.label should be translated with context.
    
     * Translate the label strings when using them.
     * Require that the 'column' context is used.

 gcr/gcr-certificate.c |    6 +++---
 gcr/gcr-column.c      |    7 +++++++
 gcr/gcr-selector.c    |   10 ++++++++--
 3 files changed, 18 insertions(+), 5 deletions(-)
---
diff --git a/gcr/gcr-certificate.c b/gcr/gcr-certificate.c
index c5d6403..8fddb65 100644
--- a/gcr/gcr-certificate.c
+++ b/gcr/gcr-certificate.c
@@ -386,11 +386,11 @@ gcr_certificate_get_columns (void)
 {
 	static GcrColumn columns[] = {
 		{ "icon", /* later */ 0, /* later */ 0, NULL, 0 },
-		{ "label", G_TYPE_STRING, G_TYPE_STRING, N_("Name"),
+		{ "label", G_TYPE_STRING, G_TYPE_STRING, NC_("column", "Name"),
 		  GCR_COLUMN_SORTABLE },
-		{ "issuer", G_TYPE_STRING, G_TYPE_STRING, N_("Issued By"),
+		{ "issuer", G_TYPE_STRING, G_TYPE_STRING, NC_("column", "Issued By"),
 		  GCR_COLUMN_SORTABLE },
-		{ "expiry", /* later */ 0, G_TYPE_STRING, N_("Expires"),
+		{ "expiry", /* later */ 0, G_TYPE_STRING, NC_("column", "Expires"),
 		  GCR_COLUMN_SORTABLE, on_transform_date_to_string },
 		{ NULL }
 	};
diff --git a/gcr/gcr-column.c b/gcr/gcr-column.c
index 826b0e3..2396d43 100644
--- a/gcr/gcr-column.c
+++ b/gcr/gcr-column.c
@@ -55,4 +55,11 @@
  * @user_data: User data associated with the column
  *
  * Represents a column to display in a #GcrCollectionModel or #GcrSelector.
+ *
+ * The label should be set as a translatable string with a context of
+ * <code>"column"</code>. This should be done with with this macro:
+ *
+ * <informalexample><programlisting>
+ * NC_("column", "My Column Name")
+ * </programlisting></informalexample>
  */
diff --git a/gcr/gcr-selector.c b/gcr/gcr-selector.c
index 4d814df..cfb7c7d 100644
--- a/gcr/gcr-selector.c
+++ b/gcr/gcr-selector.c
@@ -25,6 +25,8 @@
 #include "gcr-internal.h"
 #include "gcr-selector.h"
 
+#include <glib/gi18n-lib.h>
+
 #include <string.h>
 
 /**
@@ -192,13 +194,15 @@ add_string_column (GcrSelector *self, const GcrColumn *column, gint column_id)
 {
 	GtkCellRenderer *cell;
 	GtkTreeViewColumn *col;
+	const gchar *label;
 
 	g_assert (column->column_type == G_TYPE_STRING);
 	g_assert (!(column->flags & GCR_COLUMN_HIDDEN));
 
 	cell = gtk_cell_renderer_text_new ();
 	g_object_set (G_OBJECT (cell), "ellipsize", PANGO_ELLIPSIZE_END, NULL);
-	col = gtk_tree_view_column_new_with_attributes (column->label, cell, "text", column_id, NULL);
+	label = g_dpgettext2 (NULL, "column", column->label);
+	col = gtk_tree_view_column_new_with_attributes (label, cell, "text", column_id, NULL);
 	gtk_tree_view_column_set_resizable (col, TRUE);
 	if (column->flags & GCR_COLUMN_SORTABLE)
 		gtk_tree_view_column_set_sort_column_id (col, column_id);
@@ -210,13 +214,15 @@ add_icon_column (GcrSelector *self, const GcrColumn *column, gint column_id)
 {
 	GtkCellRenderer *cell;
 	GtkTreeViewColumn *col;
+	const gchar *label;
 
 	g_assert (column->column_type == G_TYPE_ICON);
 	g_assert (!(column->flags & GCR_COLUMN_HIDDEN));
 
 	cell = gtk_cell_renderer_pixbuf_new ();
 	g_object_set (cell, "stock-size", GTK_ICON_SIZE_BUTTON, NULL);
-	col = gtk_tree_view_column_new_with_attributes (column->label, cell, "gicon", column_id, NULL);
+	label = g_dpgettext2 (NULL, "column", column->label);
+	col = gtk_tree_view_column_new_with_attributes (label, cell, "gicon", column_id, NULL);
 	gtk_tree_view_column_set_resizable (col, TRUE);
 	if (column->flags & GCR_COLUMN_SORTABLE)
 		gtk_tree_view_column_set_sort_column_id (col, column_id);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]