[caribou] Added i18n support.



commit b1da2367a8cec46491cd7ebee63ea8cf9553de03
Author: Eitan Isaacson <eitan monotonous org>
Date:   Sun May 16 18:10:18 2010 -0700

    Added i18n support.

 .gitignore          |    8 ++++++++
 Makefile.am         |    2 +-
 caribou/Makefile.am |    5 ++++-
 caribou/i18n.py.in  |   21 +++++++++++++++++++++
 caribou/main.py     |    1 +
 configure.ac        |   12 +++++++-----
 po/POTFILES.in      |    3 +++
 7 files changed, 45 insertions(+), 7 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 81000e8..6fff153 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,3 +14,11 @@ bin/caribou
 install-sh
 missing
 py-compile
+caribou/i18n.py
+mkinstalldirs
+po/Makefile.in.in
+po/POTFILES
+po/stamp-it
+*.gmo
+m4/intltool.m4
+
diff --git a/Makefile.am b/Makefile.am
index 6ee3575..60d3a68 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,3 +1,3 @@
 ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
 
-SUBDIRS = caribou bin data
+SUBDIRS = caribou bin data po
diff --git a/caribou/Makefile.am b/caribou/Makefile.am
index 7157fe6..dda528c 100644
--- a/caribou/Makefile.am
+++ b/caribou/Makefile.am
@@ -8,7 +8,10 @@ caribou_PYTHON = \
 	keyboard.py \
 	main.py \
 	opacity.py \
-	window.py
+	window.py \
+	i18n.py
+
+DISTCLEANFILES = i18n.py
 
 clean-local:
 	rm -rf *.pyc *.pyo
diff --git a/caribou/i18n.py.in b/caribou/i18n.py.in
new file mode 100644
index 0000000..067283a
--- /dev/null
+++ b/caribou/i18n.py.in
@@ -0,0 +1,21 @@
+import gettext
+from gettext import gettext as _
+import os
+
+print 'initialized i18n'
+
+def C_(ctx, s):
+    """Provide qualified translatable strings via context.
+    (copied from Orca)"""
+    translated = gettext.gettext('%s\x04%s' % (ctx, s))
+    if '\x04' in translated:
+        # no translation found, return input string
+        return s
+    return translated
+
+gettext.bindtextdomain ("@GETTEXT_PACKAGE@",
+                        os.path.join ("@prefix@", "@DATADIRNAME@", "locale"))
+
+gettext.textdomain("@GETTEXT_PACKAGE@")
+
+
diff --git a/caribou/main.py b/caribou/main.py
index aef9488..6c978de 100644
--- a/caribou/main.py
+++ b/caribou/main.py
@@ -3,6 +3,7 @@ import pyatspi
 import gconf
 from window import CaribouWindowEntry
 from keyboard import CaribouKeyboard
+from i18n import _
 
 debug = False
 
diff --git a/configure.ac b/configure.ac
index cac2ab3..d7cb601 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,13 +26,13 @@ AC_SUBST(CARIBOU_CFLAGS)
 AC_SUBST(CARIBOU_LIBS)
 
 dnl == i18n ==
-#GETTEXT_PACKAGE=caribou
-#AC_SUBST(GETTEXT_PACKAGE)
-#AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [The gettext package])
-#AM_GLIB_GNU_GETTEXT
+GETTEXT_PACKAGE=caribou
+AC_SUBST(GETTEXT_PACKAGE)
+AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [The gettext package])
+AM_GLIB_GNU_GETTEXT
 
 dnl == intltool check ==
-#IT_PROG_INTLTOOL([0.35.0])
+IT_PROG_INTLTOOL([0.35.0])
 
 dnl == Documentation ==
 GNOME_DOC_INIT
@@ -40,8 +40,10 @@ GNOME_DOC_INIT
 dnl == generate makefiles ==
 AC_OUTPUT([
 Makefile
+po/Makefile.in
 caribou/Makefile
 caribou/keyboards/Makefile
+caribou/i18n.py
 bin/Makefile
 bin/caribou
 data/Makefile
diff --git a/po/LINGUAS b/po/LINGUAS
new file mode 100644
index 0000000..e69de29
diff --git a/po/POTFILES.in b/po/POTFILES.in
new file mode 100644
index 0000000..1fe1c67
--- /dev/null
+++ b/po/POTFILES.in
@@ -0,0 +1,3 @@
+[encoding: UTF-8]
+caribou/main.py
+[type: gettext/glade]data/caribou-prefs.ui



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