[evolution-kolab/ek-wip-gui: 13/22] EPlugin: made Kolab PIM account setup translatable



commit 997323c8795d85b136c519f7249c78f5b65bdb4c
Author: Christian Hilberg <hilberg kernelconcepts de>
Date:   Wed Feb 15 20:08:09 2012 +0100

    EPlugin: made Kolab PIM account setup translatable
    
    * use i18n _() for translatable strings in
      the account setup
    * changed the implementation of the array of to-be-
      translated description strings for PIM account
      setup to a getter-function-based approach, so
      the strings can be translatable
    * added the changed implementation files to the
      po/POTFILE.in

 po/POTFILES.in                      |    2 +
 src/eplugin/e-kolab-account-setup.c |   56 ++++++++++++++++++--------
 src/libekolab/kolab-types.h         |   13 ------
 src/libekolab/kolab-util-backend.c  |   75 ++++++++++++++++++++++++++++++----
 src/libekolab/kolab-util-backend.h  |    3 +
 5 files changed, 110 insertions(+), 39 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index a1d6179..58a77ce 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -11,3 +11,5 @@ src/camel/providers/imapx/camel-imapx-provider.c
 src/camel/providers/imapx/camel-imapx-server.c
 src/camel/providers/imapx/camel-imapx-store.c
 src/camel/providers/imapx/camel-imapx-stream.c
+src/eplugin/e-kolab-account-setup.c
+src/libekolab/kolab-util-backend.c
diff --git a/src/eplugin/e-kolab-account-setup.c b/src/eplugin/e-kolab-account-setup.c
index 24700e0..1bd5305 100644
--- a/src/eplugin/e-kolab-account-setup.c
+++ b/src/eplugin/e-kolab-account-setup.c
@@ -28,6 +28,8 @@
 
 #include <config.h>
 
+#include <glib/gi18n-lib.h>
+
 #include <addressbook/gui/widgets/eab-config.h>
 #include <e-util/e-plugin-util.h>
 #include <libecal/e-cal.h>
@@ -78,10 +80,10 @@ static void
 ensure_kolab_sourcetype_source_group (ECalSourceType type)
 {
 	/* find the original code in google-source.c */
-	ESourceList  *slist;
+	ESourceList *slist = NULL;
 
 	if (!e_cal_get_sources (&slist, type, NULL)) {
-		g_warning ("Could not get calendar source list from GConf!");
+		g_warning ("Could not get calendar source list from GConf");
 		return;
 	}
 
@@ -121,7 +123,6 @@ set_ui_from_source (kolab_ui_data *uidata)
 	CamelURL *c_url = NULL;
 	GError *tmp_error = NULL;
 
-	g_debug ("%s()[%u] called.", __func__, __LINE__);
 	g_return_if_fail ((uidata != NULL) && (uidata->source != NULL));
 
 	source = uidata->source;
@@ -349,6 +350,7 @@ e_kolab_account_setup_backend_create (EPlugin *epl,
 	/* const gchar *base_uri = NULL; */
 	kolab_ui_data *uidata = NULL;
 	gint i;
+	gchar *tmp_str = NULL;
 
 	g_assert (E_IS_PLUGIN (epl));
 
@@ -376,7 +378,9 @@ e_kolab_account_setup_backend_create (EPlugin *epl,
 
 	/* Server section */
 	section = gtk_label_new (NULL);
-	gtk_label_set_markup (GTK_LABEL (section), "<b>Kolab Server Settings</b>");
+	tmp_str = g_strconcat ("<b>", _("Kolab Server Settings"), "</b>", NULL);
+	gtk_label_set_markup (GTK_LABEL (section), tmp_str);
+	g_free (tmp_str);
 	gtk_misc_set_alignment (GTK_MISC (section), 0.0, 0.0);
 	gtk_box_pack_start (GTK_BOX (kolab_vbox), section, FALSE, FALSE, 0);
 
@@ -385,7 +389,9 @@ e_kolab_account_setup_backend_create (EPlugin *epl,
 	gtk_box_pack_start (GTK_BOX (kolab_vbox), GTK_WIDGET (hbox), TRUE, TRUE, 0);
 	spacer = gtk_label_new("   ");
 	gtk_box_pack_start (GTK_BOX (hbox), spacer, FALSE, FALSE, 0);
-	label = gtk_label_new_with_mnemonic("Kolab Account:");
+	tmp_str = g_strconcat (_("Kolab Account"), ":", NULL);
+	label = gtk_label_new_with_mnemonic (tmp_str);
+	g_free (tmp_str);
 	gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
 	uidata->kolab_accounts_avail = GTK_COMBO_BOX_TEXT (gtk_combo_box_text_new ());
 	gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (uidata->kolab_accounts_avail), TRUE, TRUE, 0);
@@ -398,7 +404,9 @@ e_kolab_account_setup_backend_create (EPlugin *epl,
 	gtk_box_pack_start (GTK_BOX (kolab_vbox), GTK_WIDGET (hbox), TRUE, TRUE, 0);
 	spacer = gtk_label_new("   ");
 	gtk_box_pack_start (GTK_BOX (hbox), spacer, FALSE, FALSE, 0);
-	label = gtk_label_new("Kolab Server:");
+	tmp_str = g_strconcat (_("Kolab Server"), ":", NULL);
+	label = gtk_label_new(tmp_str);
+	g_free (tmp_str);
 	gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
 	uidata->kolab_servername = GTK_ENTRY(gtk_entry_new());
 	gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (uidata->kolab_servername), TRUE, TRUE, 0);
@@ -408,7 +416,9 @@ e_kolab_account_setup_backend_create (EPlugin *epl,
 	gtk_box_pack_start (GTK_BOX (kolab_vbox), GTK_WIDGET (hbox), TRUE, TRUE, 0);
 	spacer = gtk_label_new("   ");
 	gtk_box_pack_start (GTK_BOX (hbox), spacer, FALSE, FALSE, 0);
-	label = gtk_label_new_with_mnemonic("User Name:");
+	tmp_str = g_strconcat (_("User Name"), ":", NULL);
+	label = gtk_label_new_with_mnemonic (tmp_str);
+	g_free (tmp_str);
 	gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
 	uidata->kolab_username = GTK_ENTRY(gtk_entry_new());
 	gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (uidata->kolab_username), TRUE, TRUE, 0);
@@ -418,14 +428,16 @@ e_kolab_account_setup_backend_create (EPlugin *epl,
 	gtk_box_pack_start (GTK_BOX (kolab_vbox), GTK_WIDGET (hbox), TRUE, TRUE, 0);
 	spacer = gtk_label_new("   ");
 	gtk_box_pack_start (GTK_BOX (hbox), spacer, FALSE, FALSE, 0);
-	label = gtk_label_new_with_mnemonic ("Server Folders:");
+	tmp_str = g_strconcat (_("Server Folders"), ":", NULL);
+	label = gtk_label_new_with_mnemonic (tmp_str);
+	g_free (tmp_str);
 	gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
 	uidata->kolab_folders_avail = GTK_COMBO_BOX_TEXT (gtk_combo_box_text_new ());
 	gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (uidata->kolab_folders_avail), TRUE, TRUE, 0);
 	/* FIXME add Kolab PIM folders to GTK box */
 	g_warning ("%s: FIXME add Kolab PIM folders to GTK box", __func__);
 	gtk_combo_box_set_active (GTK_COMBO_BOX (uidata->kolab_folders_avail), 0);
-	uidata->retrieve_folder_list = GTK_BUTTON (gtk_button_new_with_label ("Retrieve"));
+	uidata->retrieve_folder_list = GTK_BUTTON (gtk_button_new_with_label (_("Retrieve")));
 	gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (uidata->retrieve_folder_list), FALSE, FALSE, 0);
 
 	/* Kolab folder name option */
@@ -434,9 +446,11 @@ e_kolab_account_setup_backend_create (EPlugin *epl,
 	spacer = gtk_label_new("   ");
 	gtk_box_pack_start (GTK_BOX (hbox), spacer, FALSE, FALSE, 0);
 	if (widget_type==KOLAB_CONTACT_WIDGET)
-		label = gtk_label_new_with_mnemonic("Contact Folder:");
+		tmp_str = g_strconcat (_("Contact Folder"), ":", NULL);
 	else
-		label = gtk_label_new_with_mnemonic("Calendar Folder:");
+		tmp_str = g_strconcat (_("Calendar Folder"), ":", NULL);
+	label = gtk_label_new_with_mnemonic (tmp_str);
+	g_free (tmp_str);
 	gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
 	uidata->kolab_foldername = GTK_ENTRY(gtk_entry_new());
 	gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (uidata->kolab_foldername), TRUE, TRUE, 0);
@@ -446,12 +460,14 @@ e_kolab_account_setup_backend_create (EPlugin *epl,
 	gtk_box_pack_start (GTK_BOX (kolab_vbox), GTK_WIDGET (hbox), TRUE, TRUE, 0);
 	spacer = gtk_label_new("   ");
 	gtk_box_pack_start (GTK_BOX (hbox), spacer, FALSE, FALSE, 0);
-	label = gtk_label_new_with_mnemonic("Encryption Method:");
+	tmp_str = g_strconcat (_("Encryption Method"), ":", NULL);
+	label = gtk_label_new_with_mnemonic(tmp_str);
+	g_free (tmp_str);
 	gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
 	uidata->encryption_method = GTK_COMBO_BOX_TEXT (gtk_combo_box_text_new ());
 	gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (uidata->encryption_method), TRUE, TRUE, 0);
 	for (i = KOLAB_TLS_FIRST_VARIANT; i < KOLAB_TLS_LAST_VARIANT; i++) {
-		gtk_combo_box_text_append (uidata->encryption_method, NULL, kolab_tls_variant_desc[i]);
+		gtk_combo_box_text_append (uidata->encryption_method, NULL, kolab_util_backend_get_tls_variant_desc(i));
 	}
 	gtk_combo_box_set_active (GTK_COMBO_BOX (uidata->encryption_method), KOLAB_TLS_VARIANT_DEFAULT);
 
@@ -460,7 +476,9 @@ e_kolab_account_setup_backend_create (EPlugin *epl,
 	gtk_box_pack_start (GTK_BOX (kolab_vbox), GTK_WIDGET (hbox), TRUE, TRUE, 0);
 	spacer = gtk_label_new("   ");
 	gtk_box_pack_start (GTK_BOX (hbox), spacer, FALSE, FALSE, 0);
-	label = gtk_label_new_with_mnemonic("PKCS #11 Infrastructure:");
+	tmp_str = g_strconcat (_("PKCS #11 Infrastructure"), ":", NULL);
+	label = gtk_label_new_with_mnemonic(tmp_str);
+	g_free (tmp_str);
 	gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
 	uidata->require_pkcs11_infrastructure = GTK_CHECK_BUTTON (gtk_check_button_new_with_label ("PIN:"));
 	gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (uidata->require_pkcs11_infrastructure), TRUE, TRUE, 0);
@@ -470,7 +488,9 @@ e_kolab_account_setup_backend_create (EPlugin *epl,
 
 	/* Options section */
 	section = gtk_label_new (NULL);
-	gtk_label_set_markup (GTK_LABEL (section), "<b>Kolab Folder Options</b>");
+	tmp_str = g_strconcat ("<b>", _("Kolab Folder Options"), "</b>", NULL);
+	gtk_label_set_markup (GTK_LABEL (section), tmp_str);
+	g_free (tmp_str);
 	gtk_misc_set_alignment (GTK_MISC (section), 0.0, 0.0);
 	gtk_box_pack_start (GTK_BOX (kolab_vbox), section, FALSE, FALSE, 0);
 
@@ -478,12 +498,14 @@ e_kolab_account_setup_backend_create (EPlugin *epl,
 	gtk_box_pack_start (GTK_BOX (kolab_vbox), GTK_WIDGET (hbox), TRUE, TRUE, 0);
 	spacer = gtk_label_new ("   ");
 	gtk_box_pack_start (GTK_BOX (hbox), spacer, FALSE, FALSE, 0);
-	label = gtk_label_new_with_mnemonic ("Conflict Solving Strategy:");
+	tmp_str = g_strconcat (_("Conflict Solving Strategy"), ":", NULL);
+	label = gtk_label_new_with_mnemonic (tmp_str);
+	g_free (tmp_str);
 	gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
 	uidata->kolab_conflict_strategy = GTK_COMBO_BOX_TEXT (gtk_combo_box_text_new ());
 	gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (uidata->kolab_conflict_strategy), TRUE, TRUE, 0);
 	for (i = KOLAB_SYNC_FIRST_STRATEGY; i < KOLAB_SYNC_LAST_STRATEGY; i++) {
-		gtk_combo_box_text_append (uidata->kolab_conflict_strategy, NULL, kolab_sync_strategy_desc[i]);
+		gtk_combo_box_text_append (uidata->kolab_conflict_strategy, NULL, kolab_util_backend_get_sync_strategy_desc(i));
 	}
 	gtk_combo_box_set_active (GTK_COMBO_BOX (uidata->kolab_conflict_strategy), KOLAB_SYNC_STRATEGY_DEFAULT);
 
diff --git a/src/libekolab/kolab-types.h b/src/libekolab/kolab-types.h
index 591161a..b9c0f5b 100644
--- a/src/libekolab/kolab-types.h
+++ b/src/libekolab/kolab-types.h
@@ -42,12 +42,6 @@ typedef enum {
 	KOLAB_TLS_VARIANT_DEFAULT = KOLAB_TLS_VARIANT_STARTTLS
 } KolabTLSVariantID;
 
-#define KOLAB_TLS_DESC_VARIANT_NONE "No encryption"
-#define KOLAB_TLS_DESC_VARIANT_SSL "SSL encryption"
-#define KOLAB_TLS_DESC_VARIANT_TLS "TLS encryption"
-
-const gchar *kolab_tls_variant_desc[KOLAB_TLS_LAST_VARIANT];
-
 #define KOLAB_TLS_VARIANT_PROP "kolab-encryption-method"
 
 /* PIM data conflict resolution variants */
@@ -61,13 +55,6 @@ typedef enum {
 	KOLAB_SYNC_STRATEGY_DEFAULT = KOLAB_SYNC_STRATEGY_NEWEST
 } KolabSyncStrategyID;
 
-#define KOLAB_STRATEGY_DESC_NEWEST	"Take Newer (last modified)"
-#define KOLAB_STRATEGY_DESC_SERVER	"Take Remote (server-side)"
-#define KOLAB_STRATEGY_DESC_CLIENT	"Take Local (client-side)"
-#define KOLAB_STRATEGY_DESC_DUPE	"Take Both (resulting in two different, parallel entries)"
-
-const gchar *kolab_sync_strategy_desc[KOLAB_SYNC_LAST_STRATEGY];
-
 #define KOLAB_SYNC_STRATEGY_PROP "kolab-sync-strategy"
 
 typedef enum {
diff --git a/src/libekolab/kolab-util-backend.c b/src/libekolab/kolab-util-backend.c
index cf44ee2..fc641f7 100644
--- a/src/libekolab/kolab-util-backend.c
+++ b/src/libekolab/kolab-util-backend.c
@@ -25,8 +25,13 @@
 
 /*----------------------------------------------------------------------------*/
 
+#include <config.h>
+
 #include <string.h>
 #include <time.h>
+
+#include <glib/gi18n-lib.h>
+
 #include <libical/ical.h>
 #include <libedataserver/e-source.h>
 
@@ -37,20 +42,39 @@
 
 #include "kolab-util-backend.h"
 
-const gchar *kolab_sync_strategy_desc[KOLAB_SYNC_LAST_STRATEGY] = {
-	KOLAB_STRATEGY_DESC_NEWEST,
-	KOLAB_STRATEGY_DESC_SERVER,
-	KOLAB_STRATEGY_DESC_CLIENT,
-	KOLAB_STRATEGY_DESC_DUPE
+static const gchar *kolab_sync_strategy_desc[KOLAB_SYNC_LAST_STRATEGY] = {
+	NULL, NULL, NULL, NULL
 };
 
-const gchar *kolab_tls_variant_desc[KOLAB_TLS_LAST_VARIANT] = {
-	KOLAB_TLS_DESC_VARIANT_NONE,
-	KOLAB_TLS_DESC_VARIANT_SSL,
-	KOLAB_TLS_DESC_VARIANT_TLS
+static const gchar *kolab_tls_variant_desc[KOLAB_TLS_LAST_VARIANT] = {
+	NULL, NULL, NULL
 };
 
 /*----------------------------------------------------------------------------*/
+/* local statics */
+
+static void
+kolab_util_backend_init_sync_strategy_desc (void)
+{
+	kolab_sync_strategy_desc[KOLAB_SYNC_STRATEGY_NEWEST] = \
+		_("Take Newer (last modified)");
+	kolab_sync_strategy_desc[KOLAB_SYNC_STRATEGY_SERVER] = \
+		_("Take Remote (server-side)");
+	kolab_sync_strategy_desc[KOLAB_SYNC_STRATEGY_CLIENT] = \
+		_("Take Local (client-side)");
+	kolab_sync_strategy_desc[KOLAB_SYNC_STRATEGY_DUPE] = \
+		_("Take Both (resulting in two different, parallel entries)");
+}
+
+static void
+kolab_util_backend_init_tls_variant_desc (void)
+{
+	kolab_tls_variant_desc[KOLAB_TLS_VARIANT_NONE] = _("No encryption");
+	kolab_tls_variant_desc[KOLAB_TLS_VARIANT_SSL] = _("SSL encryption");
+	kolab_tls_variant_desc[KOLAB_TLS_VARIANT_STARTTLS] = _("TLS encryption");
+}
+
+/*----------------------------------------------------------------------------*/
 /* GError for libekolabbackend */
 
 GQuark
@@ -410,3 +434,36 @@ kolab_util_backend_sqlite_db_new_open (KolabUtilSqliteDb **kdb,
 
 	return TRUE;
 }
+
+/*----------------------------------------------------------------------------*/
+/* mapping of description IDs to description strings */
+
+const gchar*
+kolab_util_backend_get_sync_strategy_desc (KolabSyncStrategyID id)
+{
+	static gboolean initialized = FALSE;
+
+	g_assert (id < KOLAB_SYNC_LAST_STRATEGY);
+
+	if (! initialized) {
+		kolab_util_backend_init_sync_strategy_desc ();
+		initialized = TRUE;
+	}
+
+	return kolab_sync_strategy_desc[id];
+}
+
+const gchar*
+kolab_util_backend_get_tls_variant_desc (KolabTLSVariantID id)
+{
+	static gboolean initialized = FALSE;
+
+	g_assert (id < KOLAB_TLS_LAST_VARIANT);
+
+	if (! initialized) {
+		kolab_util_backend_init_tls_variant_desc ();
+		initialized = TRUE;
+	}
+
+	return kolab_tls_variant_desc[id];
+}
diff --git a/src/libekolab/kolab-util-backend.h b/src/libekolab/kolab-util-backend.h
index ab1278b..2516470 100644
--- a/src/libekolab/kolab-util-backend.h
+++ b/src/libekolab/kolab-util-backend.h
@@ -84,6 +84,9 @@ void kolab_util_backend_prepare_settings (KolabSettingsHandler *ksettings, ESour
 
 gboolean kolab_util_backend_sqlite_db_new_open (KolabUtilSqliteDb **kdb, KolabSettingsHandler *ksettings, const gchar *dbfilename, GError **err);
 
+const gchar *kolab_util_backend_get_sync_strategy_desc (KolabSyncStrategyID id);
+const gchar *kolab_util_backend_get_tls_variant_desc (KolabTLSVariantID id);
+
 /*----------------------------------------------------------------------------*/
 
 #endif /* _KOLAB_UTIL_BACKEND_H_ */



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