Add gettext support to Tilda
authorIra W. Snyder <devel@irasnyder.com>
Fri, 18 Jan 2008 09:22:15 +0000 (01:22 -0800)
committerIra W. Snyder <devel@irasnyder.com>
Fri, 18 Jan 2008 09:22:15 +0000 (01:22 -0800)
This adds proper gettext support to Tilda, so that it can be
internationalized at a later date. Not all strings are marked, yet.

Note that this will not work as-is, because some additional #define's
are needed. They will be provided when the project is autoconfed.

tilda-terminal.c
tilda.c
tilda.h

index 57f14b0..c91ee8a 100644 (file)
@@ -2,11 +2,6 @@
 #include "tilda-terminal.h"
 #include "tilda-terminal-dbus-glue.h"
 
 #include "tilda-terminal.h"
 #include "tilda-terminal-dbus-glue.h"
 
-// FIXME: temporary helpers for gettext
-// TODO:  remove these
-#define _(X) X
-#define N_(X) X
-
 #define DINGUS1 "(((news|telnet|nttp|file|http|ftp|https)://)|(www|ftp)[-A-Za-z0-9]*\\.)[-A-Za-z0-9\\.]+(:[0-9]*)?"
 #define DINGUS2 "(((news|telnet|nttp|file|http|ftp|https)://)|(www|ftp)[-A-Za-z0-9]*\\.)[-A-Za-z0-9\\.]+(:[0-9]*)?/[-A-Za-z0-9_\\$\\.\\+\\!\\*\\(\\),;:@&=\\?/~\\#\\%]*[^]'\\.}>\\) ,\\\"]"
 
 #define DINGUS1 "(((news|telnet|nttp|file|http|ftp|https)://)|(www|ftp)[-A-Za-z0-9]*\\.)[-A-Za-z0-9\\.]+(:[0-9]*)?"
 #define DINGUS2 "(((news|telnet|nttp|file|http|ftp|https)://)|(www|ftp)[-A-Za-z0-9]*\\.)[-A-Za-z0-9\\.]+(:[0-9]*)?/[-A-Za-z0-9_\\$\\.\\+\\!\\*\\(\\),;:@&=\\?/~\\#\\%]*[^]'\\.}>\\) ,\\\"]"
 
diff --git a/tilda.c b/tilda.c
index e13ca49..c712fc7 100644 (file)
--- a/tilda.c
+++ b/tilda.c
@@ -119,6 +119,13 @@ int main (int argc, char *argv[])
 
        TildaWindow *tw;
 
 
        TildaWindow *tw;
 
+#if ENABLE_NLS
+       /* Gettext Initialization */
+       setlocale (LC_ALL, "");
+       bindtextdomain (PACKAGE, LOCALEDIR);
+       textdomain (PACKAGE);
+#endif
+
        /* Initialize GTK+ (and the GObject system) */
        gtk_init (&argc, &argv);
 
        /* Initialize GTK+ (and the GObject system) */
        gtk_init (&argc, &argv);
 
diff --git a/tilda.h b/tilda.h
index c0df133..96adfa1 100644 (file)
--- a/tilda.h
+++ b/tilda.h
        #define debug_assert(args...) do { /* nothing */ } while (0)
 #endif
 
        #define debug_assert(args...) do { /* nothing */ } while (0)
 #endif
 
+/* Optional gettext translation macros */
+#ifdef ENABLE_NLS
+       #include <glib/gi18n.h>
+#else
+       #define _(X) X
+       #define N_(X) X
+#endif
+
 /* Project-global variables */
 extern DBusGConnection *dbus_connection;
 
 /* Project-global variables */
 extern DBusGConnection *dbus_connection;