Add l10n support.
authorSalvatore Iovene <salvatore@iovene.com>
Sat, 12 Dec 2009 14:44:34 +0000 (16:44 +0200)
committerSalvatore Iovene <salvatore@iovene.com>
Sat, 12 Dec 2009 14:45:29 +0000 (16:45 +0200)
15 files changed:
Makefile.am
autogen.sh [new file with mode: 0755]
config.h.in
configure.ac
debian/rules
debian/tweakr.install
modules/tweakr-desktop.c
modules/tweakr-mce.c
po/Makefile.am [new file with mode: 0644]
po/POTFILES.in [new file with mode: 0644]
po/en_GB.po [new file with mode: 0644]
po/en_US.po [new symlink]
po/it_IT.po [new file with mode: 0644]
tweakr.c
tweakr.desktop

index 3454fff..9b576d4 100644 (file)
@@ -1,4 +1,4 @@
-SUBDIRS = libtweakr-section modules
+SUBDIRS = libtweakr-section modules po
 
 libtweakr_section = \
        $(top_builddir)/libtweakr-section/libtweakr-section.la
diff --git a/autogen.sh b/autogen.sh
new file mode 100755 (executable)
index 0000000..8d8a56d
--- /dev/null
@@ -0,0 +1,9 @@
+set -x
+glib-gettextize --copy --force
+libtoolize --automake --copy --force
+aclocal
+intltoolize --automake --copy --force
+autoconf --force
+autoheader --force
+automake --add-missing --copy --force-missing --foreign
+
index 09ee04c..1732df1 100644 (file)
@@ -1,5 +1,8 @@
 /* config.h.in.  Generated from configure.ac by autoheader.  */
 
+/* gettext pakname */
+#undef GETTEXT_PACKAGE
+
 /* Define to 1 if you have the <dlfcn.h> header file. */
 #undef HAVE_DLFCN_H
 
index 45cef37..b47eda0 100644 (file)
@@ -9,6 +9,13 @@ AM_PROG_CC_STDC
 AC_HEADER_STDC
 AC_PROG_LIBTOOL
 
+AC_PROG_INTLTOOL([0.23])
+GETTEXT_PACKAGE=tweakr
+AC_SUBST(GETTEXT_PACKAGE)
+AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE], "${GETTEXT_PACKAGE}", [gettext pakname])
+ALL_LINGUAS="en_GB en_US it_IT"
+dnl AM_GLIB_GNU_GETTEXT
+
 PKG_CHECK_MODULES(GLIB, glib-2.0)
 AC_SUBST(GLIB_LIBS)
 AC_SUBST(GLIB_CFLAGS)
@@ -67,5 +74,7 @@ AC_OUTPUT([
            libtweakr-section/Makefile
            libtweakr-section/tweakr-section.pc
            modules/Makefile
+           po/Makefile.in
+           po/Makefile
            ])
 
index df05924..2d4594a 100755 (executable)
@@ -38,6 +38,7 @@ DEB_MAKE_ENVVARS := MAKEFLAGS=$(NJOBS)
 
 debian/stamp-autotools-files:
        autoreconf -v --install
+       intltoolize --copy --force --automake
        touch debian/stamp-autotools-files
 
 binary-predeb/tweakr::
index fb11dc0..4353d9e 100644 (file)
@@ -1,2 +1,3 @@
 usr/lib/hildon-control-panel/*so*
 usr/share/applications/hildon-control-panel/*.desktop
+usr/share/locale/*/LC_MESSAGES/*
index 0aa8a6e..173a2a7 100644 (file)
@@ -3,6 +3,7 @@
  */ 
 
 #include <config.h>
+#include <glib/gi18n-lib.h>
 
 #include <gtk/gtk.h>
 #include <hildon/hildon-picker-button.h>
@@ -140,7 +141,14 @@ tweakr_desktop_section_class_init
 
 GtkWidget * _build_snap_to_grid (void)
 {
-    const gchar *options[] = {"No", "Small", "Large", "Huge", NULL};
+    const gchar *options[] =
+    {
+        _("No"),
+        _("Small"),
+        _("Large"),
+        _("Huge"),
+        NULL
+    };
     gint i = 0;
     GtkWidget *button, *selector;
 
@@ -156,7 +164,7 @@ GtkWidget * _build_snap_to_grid (void)
     hildon_gtk_widget_set_theme_size (button, HILDON_SIZE_FINGER_HEIGHT);
 
     hildon_button_set_title (HILDON_BUTTON (button),
-                             "Snap icons to grid");
+                             _("Snap icons to grid"));
     gtk_button_set_alignment (GTK_BUTTON (button), 0.0f, 0.5f);
     hildon_picker_button_set_selector (HILDON_PICKER_BUTTON (button),
                                        HILDON_TOUCH_SELECTOR (selector));
@@ -210,7 +218,7 @@ tweakr_desktop_section_init (TweakrDesktopSection *section)
 
 
     iface = TWEAKR_SECTION (section);
-    iface->name = "Desktop";
+    iface->name = _("Desktop");
     iface->widget = gtk_vbox_new (FALSE, 0);
     gtk_box_pack_start (GTK_BOX (iface->widget), section->snap_button,
                         FALSE, FALSE, 0);
index 08eb294..31c2651 100644 (file)
@@ -3,6 +3,7 @@
  */ 
 
 #include <config.h>
+#include <glib/gi18n-lib.h>
 
 #include <gtk/gtk.h>
 #include <hildon/hildon-picker-button.h>
         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
         TWEAKR_TYPE_MCE_SECTION))
 
-#define DISABLE_LABEL "Do nothing"
-#define SHOW_MENU_LABEL "Show menu"
-#define POWER_OFF_LABEL "Power off"
-#define LOCK_LABEL "Lock device"
+#define DISABLE_LABEL _("Do nothing")
+#define SHOW_MENU_LABEL _("Show menu")
+#define POWER_OFF_LABEL _("Power off")
+#define LOCK_LABEL _("Lock device")
 
 enum {
     SHORT_POWER_KEY_DISABLED,
@@ -63,25 +64,9 @@ typedef struct _picker_t
     const gchar *label;
 } picker_t;
 
-static picker_t spk [] = {
-    {SHORT_POWER_KEY_DISABLED, "disabled", DISABLE_LABEL},
-    {SHORT_POWER_KEY_MENU, "menu", SHOW_MENU_LABEL},
-    {SHORT_POWER_KEY_OFF, "poweroff", POWER_OFF_LABEL}
-};
-
-static picker_t lpk [] = {
-    {LONG_POWER_KEY_DISABLED, "disabled", DISABLE_LABEL},
-    {LONG_POWER_KEY_MENU, "menu", SHOW_MENU_LABEL},
-    {LONG_POWER_KEY_OFF, "poweroff", POWER_OFF_LABEL}
-};
-
-static picker_t dpk [] = {
-    {DOUBLE_POWER_KEY_DISABLED, "disabled", DISABLE_LABEL},
-    {DOUBLE_POWER_KEY_MENU, "menu", SHOW_MENU_LABEL},
-    {DOUBLE_POWER_KEY_OFF, "poweroff", POWER_OFF_LABEL},
-    {DOUBLE_POWER_KEY_LOCK, "tklock", LOCK_LABEL}
-};
-
+static picker_t spk [SHORT_POWER_KEY_N];
+static picker_t lpk [LONG_POWER_KEY_N];
+static picker_t dpk [DOUBLE_POWER_KEY_N];
 
 typedef struct _TweakrMceSection TweakrMceSection;
 typedef struct _TweakrMceSectionClass
@@ -195,6 +180,18 @@ GtkWidget * _build_short_power_key (TweakrMceSection *section)
     gint i;
     GtkWidget *button, *selector;
 
+    spk[0].index = SHORT_POWER_KEY_DISABLED;
+    spk[0].value = "disabled";
+    spk[0].label = DISABLE_LABEL;
+
+    spk[1].index = SHORT_POWER_KEY_MENU;
+    spk[1].value = "menu";
+    spk[1].label = SHOW_MENU_LABEL;
+
+    spk[2].index = SHORT_POWER_KEY_OFF;
+    spk[2].value = "poweroff";
+    spk[2].label = POWER_OFF_LABEL;
+
     selector = hildon_touch_selector_new_text ();
     for (i = 0; i < SHORT_POWER_KEY_N; i++)
     {
@@ -207,7 +204,7 @@ GtkWidget * _build_short_power_key (TweakrMceSection *section)
     hildon_gtk_widget_set_theme_size (button, HILDON_SIZE_FINGER_HEIGHT);
 
     hildon_button_set_title (HILDON_BUTTON (button),
-                             "Power key: short press");
+                             _("Power key short press"));
     gtk_button_set_alignment (GTK_BUTTON (button), 0.0f, 0.5f);
     hildon_picker_button_set_selector (HILDON_PICKER_BUTTON (button),
                                        HILDON_TOUCH_SELECTOR (selector));
@@ -223,6 +220,18 @@ GtkWidget * _build_long_power_key (TweakrMceSection *section)
 {
     gint i;
     GtkWidget *button, *selector;
+    
+    lpk[0].index = LONG_POWER_KEY_DISABLED;
+    lpk[0].value = "disabled";
+    lpk[0].label = DISABLE_LABEL;
+
+    lpk[1].index = LONG_POWER_KEY_MENU;
+    lpk[1].value = "menu";
+    lpk[1].label = SHOW_MENU_LABEL;
+
+    lpk[2].index = LONG_POWER_KEY_OFF;
+    lpk[2].value = "poweroff";
+    lpk[2].label = POWER_OFF_LABEL;
 
     selector = hildon_touch_selector_new_text ();
     for (i = 0; i < LONG_POWER_KEY_N; i++)
@@ -236,7 +245,7 @@ GtkWidget * _build_long_power_key (TweakrMceSection *section)
     hildon_gtk_widget_set_theme_size (button, HILDON_SIZE_FINGER_HEIGHT);
 
     hildon_button_set_title (HILDON_BUTTON (button),
-                             "Power key: long press");
+                             _("Power key long press"));
     gtk_button_set_alignment (GTK_BUTTON (button), 0.0f, 0.5f);
     hildon_picker_button_set_selector (HILDON_PICKER_BUTTON (button),
                                        HILDON_TOUCH_SELECTOR (selector));
@@ -253,6 +262,22 @@ GtkWidget * _build_double_power_key (TweakrMceSection *section)
     gint i;
     GtkWidget *button, *selector;
 
+    dpk[0].index = DOUBLE_POWER_KEY_DISABLED;
+    dpk[0].value = "disabled";
+    dpk[0].label = DISABLE_LABEL;
+
+    dpk[1].index = DOUBLE_POWER_KEY_MENU;
+    dpk[1].value = "menu";
+    dpk[1].label = SHOW_MENU_LABEL;
+
+    dpk[2].index = DOUBLE_POWER_KEY_OFF;
+    dpk[2].value = "poweroff";
+    dpk[2].label = POWER_OFF_LABEL;
+
+    dpk[3].index = DOUBLE_POWER_KEY_LOCK;
+    dpk[3].value = "tklock";
+    dpk[3].label = LOCK_LABEL;
+
     selector = hildon_touch_selector_new_text ();
     for (i = 0; i < DOUBLE_POWER_KEY_N; i++)
     {
@@ -265,7 +290,7 @@ GtkWidget * _build_double_power_key (TweakrMceSection *section)
     hildon_gtk_widget_set_theme_size (button, HILDON_SIZE_FINGER_HEIGHT);
 
     hildon_button_set_title (HILDON_BUTTON (button),
-                             "Power key: double press");
+                             _("Power key long press"));
     gtk_button_set_alignment (GTK_BUTTON (button), 0.0f, 0.5f);
     hildon_picker_button_set_selector (HILDON_PICKER_BUTTON (button),
                                        HILDON_TOUCH_SELECTOR (selector));
@@ -284,7 +309,7 @@ GtkWidget *_build_lens_cover (TweakrMceSection *section)
     button = hildon_check_button_new (HILDON_SIZE_AUTO);
     hildon_gtk_widget_set_theme_size (button, HILDON_SIZE_FINGER_HEIGHT);
     gtk_button_set_label (GTK_BUTTON (button),
-                          "Opening lens cover unlocks device");
+                          _("Opening camera lens cover unlocks device"));
 
     g_signal_connect (G_OBJECT (button), "toggled",
                       G_CALLBACK (_lens_cover_changed), section);
@@ -362,7 +387,7 @@ tweakr_mce_section_init (TweakrMceSection *section)
     section->value_changed = FALSE;
 
     iface = TWEAKR_SECTION (section);
-    iface->name = "Hardware keys";
+    iface->name = _("Hardware keys");
     iface->widget = gtk_vbox_new (FALSE, 0);
     gtk_box_pack_start (GTK_BOX (iface->widget), section->short_power_key,
                         FALSE, FALSE, 0);
@@ -422,9 +447,10 @@ static gboolean _save (TweakrSection *section,
         gint retcode;
 
         note = hildon_note_new_confirmation
-            (NULL, "Setting all Power Key options to \"Do nothing\" means "
-             "that the only way to turn the device off is the removal of "
-             "the battery. Do you want to continue?");
+            (NULL,
+             _("Setting all Power Key options to \"Do nothing\" means "
+               "that the only way to turn the device off is the removal of "
+               "the battery. Do you want to continue?"));
         retcode = gtk_dialog_run (GTK_DIALOG (note));
         gtk_widget_destroy (note);
 
@@ -438,7 +464,7 @@ static gboolean _save (TweakrSection *section,
     argv[1] = g_strdup_printf ("%s", spk[short_active].value);
     argv[2] = g_strdup_printf ("%s", lpk[long_active].value);
     argv[3] = g_strdup_printf ("%s", dpk[double_active].value);
-    argv[4] = g_strdup_printf ("%s", lens_cover_value);
+    argv[4] = g_strdup_printf ("%d", lens_cover_value);
     argv[5] = NULL;
 
     g_spawn_sync ("/home/user", argv, NULL,
diff --git a/po/Makefile.am b/po/Makefile.am
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/po/POTFILES.in b/po/POTFILES.in
new file mode 100644 (file)
index 0000000..8fff522
--- /dev/null
@@ -0,0 +1,3 @@
+tweakr.c
+modules/tweakr-desktop.c
+modules/tweakr-mce.c
diff --git a/po/en_GB.po b/po/en_GB.po
new file mode 100644 (file)
index 0000000..f408e7d
--- /dev/null
@@ -0,0 +1,97 @@
+# Tweakr translation file
+# Copyright (C) 2009
+# This file is distributed under the same license as the Tweakr package.
+# Salvatore Iovene <salvatore@iovene.com>, 2009.
+#
+#: tweakr.c:58
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: Tweakr 0.0.2\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2009-12-12 11:21+0200\n"
+"PO-Revision-Date: 2009-12-12 11:21+0200\n"
+"Last-Translator: Salvatore Iovene <salvatore@iovene.com>\n"
+"Language-Team: Salvatore Iovene <salvatore@iovene.com>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: tweakr.c:128
+msgid ""
+"Some of the settings you have changed "
+"will take effect only after you restart your device."
+msgstr ""
+"Some of the settings you have changed "
+"will take effect only after you restart your device."
+
+#: modules/tweakr-desktop.c:145
+msgid  "No"
+msgstr "No"
+
+#: modules/tweakr-desktop.c:146
+msgid  "Small"
+msgstr "Small"
+
+#: modules/tweakr-desktop.c:147
+msgid  "Large"
+msgstr "Large"
+
+#: modules/tweakr-desktop.c:148
+msgid  "Huge"
+msgstr "Huge"
+
+#: modules/tweakr-desktop.c:166
+msgid  "Snap icons to grid"
+msgstr "Snap icons to grid"
+
+#: modules/tweakr-desktop.c:220
+msgid  "Desktop"
+msgstr "Desktop"
+
+#: modules/tweakr-mce.c:31
+msgid  "Do nothing"
+msgstr "Do nothing"
+
+#: modules/tweakr-mce.c:32
+msgid  "Show menu"
+msgstr "Show menu"
+
+#: modules/tweakr-mce.c:33
+msgid  "Power off"
+msgstr "Power off"
+
+#: modules/tweakr-mce.c:34
+msgid  "Lock device"
+msgstr "Lock device"
+
+#: modules/tweakr-mce.c:210
+msgid  "Power key short press"
+msgstr "Power key short press"
+
+#: modules/tweakr-mce.c:239
+msgid  "Power key long press"
+msgstr "Power key long press"
+
+#: modules/tweakr-mce.c:268
+msgid  "Power key double press"
+msgstr "Power key double press"
+
+#: modules/tweakr-mce.c:287
+msgid  "Opening camera lens cover unlocks device"
+msgstr "Opening camera lens cover unlocks device"
+
+#: modules/tweakr-mce.c:365
+msgid  "Hardware keys"
+msgstr "Hardware keys"
+
+#: modules/tweakr-mce.c:425
+msgid ""
+"Setting all Power Key options to \"Do nothing\" means "
+"that the only way to turn the device off is the removal of "
+"the battery. Do you want to continue?"
+msgstr ""
+"Setting all Power Key options to \"Do nothing\" means "
+"that the only way to turn the device off is the removal of "
+"the battery. Do you want to continue?"
+
diff --git a/po/en_US.po b/po/en_US.po
new file mode 120000 (symlink)
index 0000000..5f1ea2b
--- /dev/null
@@ -0,0 +1 @@
+en_GB.po
\ No newline at end of file
diff --git a/po/it_IT.po b/po/it_IT.po
new file mode 100644 (file)
index 0000000..6b8cdae
--- /dev/null
@@ -0,0 +1,97 @@
+# Tweakr translation file
+# Copyright (C) 2009
+# This file is distributed under the same license as the Tweakr package.
+# Salvatore Iovene <salvatore@iovene.com>, 2009.
+#
+#: tweakr.c:58
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: Tweakr 0.0.2\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2009-12-12 11:21+0200\n"
+"PO-Revision-Date: 2009-12-12 11:21+0200\n"
+"Last-Translator: Salvatore Iovene <salvatore@iovene.com>\n"
+"Language-Team: Salvatore Iovene <salvatore@iovene.com>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: tweakr.c:128
+msgid ""
+"Some of the settings you have changed "
+"will take effect only after you restart your device."
+msgstr ""
+"Alcuni dei dettaggi che hai cambiato "
+"avranno effetto solo dopo il riavvio del dispositivo."
+
+#: modules/tweakr-desktop.c:145
+msgid  "No"
+msgstr "No"
+
+#: modules/tweakr-desktop.c:146
+msgid  "Small"
+msgstr "Piccola"
+
+#: modules/tweakr-desktop.c:147
+msgid  "Large"
+msgstr "Grande"
+
+#: modules/tweakr-desktop.c:148
+msgid  "Huge"
+msgstr "Enorme"
+
+#: modules/tweakr-desktop.c:166
+msgid  "Snap icons to grid"
+msgstr "Aggancia icone alla griglia"
+
+#: modules/tweakr-desktop.c:220
+msgid  "Desktop"
+msgstr "Desktop"
+
+#: modules/tweakr-mce.c:31
+msgid  "Do nothing"
+msgstr "Ignora"
+
+#: modules/tweakr-mce.c:32
+msgid  "Show menu"
+msgstr "Mostra menu"
+
+#: modules/tweakr-mce.c:33
+msgid  "Power off"
+msgstr "Spegni il telefono"
+
+#: modules/tweakr-mce.c:34
+msgid  "Lock device"
+msgstr "Blocca schermo e tasti"
+
+#: modules/tweakr-mce.c:210
+msgid  "Power key short press"
+msgstr "Pulsante di accensione: pressione breve"
+
+#: modules/tweakr-mce.c:239
+msgid  "Power key long press"
+msgstr "Pulsante di accensione: pressione lunga"
+
+#: modules/tweakr-mce.c:268
+msgid  "Power key double press"
+msgstr "Pulsante di accensione: doppio click"
+
+#: modules/tweakr-mce.c:287
+msgid  "Opening camera lens cover unlocks device"
+msgstr "Scoprire la camera sblocca il telefono"
+
+#: modules/tweakr-mce.c:365
+msgid  "Hardware keys"
+msgstr "Pulsanti"
+
+#: modules/tweakr-mce.c:425
+msgid ""
+"Setting all Power Key options to \"Do nothing\" means "
+"that the only way to turn the device off is the removal of "
+"the battery. Do you want to continue?"
+msgstr ""
+"Impostare tutte i settaggi del Pulsante di Accensione "
+"a \"Ignora\" vuol dire che l'unico modo per spegnere "
+"il telefono sarĂ  rimuovere la batteria. Continuare?"
+
index 9ddd1cc..49387b7 100644 (file)
--- a/tweakr.c
+++ b/tweakr.c
@@ -2,6 +2,9 @@
  * vim:ts=4:sw=4:et:cindent:cino=(0
  */ 
 
+#include <config.h>
+#include <glib/gi18n-lib.h>
+
 #include <hildon-cp-plugin/hildon-cp-plugin-interface.h>
 #include <gtk/gtk.h>
 #include <hildon/hildon-note.h>
@@ -116,8 +119,9 @@ osso_return_t execute (osso_context_t *osso, gpointer data,
         GtkWidget *note;
 
         note = hildon_note_new_information
-            (GTK_WINDOW (data), "Some of the settings you have changed"
-             " will take effect only after you restart your device.");
+            (GTK_WINDOW (data),
+             _("Some of the settings you have changed "
+               "will take effect only after you restart your device."));
         gtk_dialog_run (GTK_DIALOG (note));
         gtk_widget_destroy (note);
     }
index 2aa3335..856de86 100644 (file)
@@ -7,3 +7,4 @@ Type=HildonControlPanelPlugin
 Icon=qgn_list_cp_isetup
 X-control-panel-plugin=libtweakr.so
 Categories=personalization
+X-Text-Domain=tweakr