[gnoduino] Setup i18n basic infrastructure
- From: Lucian Langa <lucilanga src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnoduino] Setup i18n basic infrastructure
- Date: Fri, 9 Sep 2011 20:50:17 +0000 (UTC)
commit cb067a0012c965948a6a556417e37ece3d118bac
Author: Claude Paroz <claude 2xlibre net>
Date: Tue Sep 6 17:36:45 2011 +0200
Setup i18n basic infrastructure
po/POTFILES.in | 10 ++++++++++
setup.py | 24 +++++++++++++++++++-----
src/ui.py | 16 ++++++++++++++++
3 files changed, 45 insertions(+), 5 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
new file mode 100644
index 0000000..5984575
--- /dev/null
+++ b/po/POTFILES.in
@@ -0,0 +1,10 @@
+src/board.py
+src/compiler.py
+src/misc.py
+src/programmer.py
+src/serialio.py
+src/srcview.py
+src/ui.py
+src/uploader.py
+ui/arduino.xml
+[type: gettext/glade]ui/main.ui
diff --git a/setup.py b/setup.py
index 06e65a0..7ec94c3 100644
--- a/setup.py
+++ b/setup.py
@@ -22,11 +22,18 @@ import os
import re
import logging
import subprocess
+import sys
from distutils.core import setup
from distutils import cmd
import distutils.command
from distutils.command.install import install as _install
-import sys
+
+try:
+ from DistUtilsExtra.command import *
+ has_extras = True
+except ImportError:
+ logging.warn("To be able to install translations, you must install python-distutils-extra.")
+ has_extras = False
def runProg(cmdline):
sout = ""
@@ -121,6 +128,16 @@ for r,d,f in os.walk("reference"):
if ".git" not in r and f:
data_files.append([os.path.join("share", "gnoduino", r), [os.path.join(r,i) for i in f]])
+cmd_classes = {
+ "pixmaps": Pixmaps,
+ "install": install,
+}
+if has_extras:
+ cmd_classes.update({
+ "build" : build_extra.build_extra,
+ "build_i18n" : build_i18n.build_i18n,
+ })
+
setup(name='gnoduino',
version=get_gnoduino_version(),
description='Gnome Arduino IDE implementation',
@@ -134,9 +151,6 @@ setup(name='gnoduino',
license='GPL',
platforms='linux',
data_files = data_files,
- cmdclass={
- "pixmaps": Pixmaps,
- "install": install,
- }
+ cmdclass=cmd_classes,
)
diff --git a/src/ui.py b/src/ui.py
index f49ff61..37f231a 100644
--- a/src/ui.py
+++ b/src/ui.py
@@ -28,6 +28,7 @@ import signal
import urlparse
import time
+import locale
import gettext
_ = gettext.gettext
@@ -44,6 +45,7 @@ import gnoduino
import gtksourceview2
font = "Monospace 10"
+APP_NAME = "gnoduino"
def setupPage(w, page, p):
misc.set_widget_font(getCurrentView(), config.cur_editor_font)
@@ -622,6 +624,15 @@ def vbox_move_handle(widget, scrolltype):
p.saveValues()
return True
+def _search_locales():
+ localedirs = ("/usr/share/locale",
+ "/usr/local/share/locale")
+ for dir in localedirs:
+ if os.path.exists(os.path.join(dir, 'fr', 'LC_MESSAGES', 'gnoduino.mo')):
+ return dir
+ # fall back to the current directory
+ return "locale/"
+
def run():
try:
global gui
@@ -640,6 +651,10 @@ def run():
global p
global b
global recentmanager
+ locale_path = _search_locales()
+ gettext.bindtextdomain(APP_NAME, locale_path)
+ gettext.textdomain(APP_NAME)
+ locale.bindtextdomain(APP_NAME, locale_path)
#global spinner
#perform cleanup prior to this
signal.signal(signal.SIGINT, signal.SIG_DFL)
@@ -649,6 +664,7 @@ def run():
recentmanager = gtk.recent_manager_get_default()
sertime = None
gui = gtk.Builder()
+ gui.set_translation_domain(APP_NAME)
try:
path = os.path.join(os.getcwd(), "ui", "main.ui")
if os.path.exists(path):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]