From 1f36bcdbc1f79012aee9847d7f3c37e38e758358 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Carlos=20Cuevas=20Albadalejo?= Date: Mon, 14 Jul 2014 12:30:46 +0200 Subject: [PATCH] Added internationalization support, updated the glade file to gtk 3.6 --- locale/es.mo | Bin 0 -> 1152 bytes locale/es.po | 76 ++++++++++++++++++++++ locale/messages.pot | 74 +++++++++++++++++++++ locale/po/es/LC_MESSAGES/jsoninspector.mo | Bin 0 -> 1152 bytes src/jsoninspector.glade | 16 +++-- src/jsoninspector.py | 35 ++++++++-- util/gen_pot.sh | 5 ++ 7 files changed, 192 insertions(+), 14 deletions(-) create mode 100644 locale/es.mo create mode 100644 locale/es.po create mode 100644 locale/messages.pot create mode 100644 locale/po/es/LC_MESSAGES/jsoninspector.mo create mode 100755 util/gen_pot.sh diff --git a/locale/es.mo b/locale/es.mo new file mode 100644 index 0000000000000000000000000000000000000000..9b6b1a199cc94ce3258f08ae08080bd5ec9bb089 GIT binary patch literal 1152 zcmZva&2H2%5XTLa0%`du2rBWVDHlLh%I>PDRZ0=dvMpQsv1*r!+saL*yQ$JRva>77 z8Sw(Z10ZqXg2V%G>VXp%4jhqq1tjkLodgOkR_vc=Job#8|F^RPuLas^^vme4&_~gS z4`D#-f({shHYNp6fzQE<;LE~(U#x!w2jKr)_`iT>V1EbCfj^4%!NWovg*{Yoq~Iv{ z0x?&>VXVJBBE)&{18DPp00_-6qwRx{$uytMsN5CoY64(Io3C3XaZh^wInwfJc&tdknCN!U-77K=&-9MGm#+mv>h{3uK|l+?k5SXTMAC=1zV+U0;Tq|}#D z805+RHOCyWl5m`#k|H^6h7pU_PQqecMm-koIqPUY-E*O#>%p@%8AmcyJR|H;NI_bjN4KkIn9-pThlC4Y;qsSls&4H%9Czs$}LY) zx#CsIUdf{cWp>|DP3lM)s`a=p4c*af zIK3AsUq)SJ(!1CecY3nJZj0r%M{9|UL(~1^_K1zM)L5$TU9db+a%u{{C`LZKi%0gI zZY7Zn;~Db1QX|Feqy!n%T+> z<dFPNUqX15 zjtmq9Yyu{Z$o?al$b=&{nT!lmSCU`EWwM004tg_Dsr>v{QGfRhly$&{tg0J2)KHV( eWo;AxU0o|ol$966-L7iC8}^l`ws(4g6u$r#y%Zz> literal 0 HcmV?d00001 diff --git a/locale/es.po b/locale/es.po new file mode 100644 index 0000000..4f43435 --- /dev/null +++ b/locale/es.po @@ -0,0 +1,76 @@ +# Spanish translations for PACKAGE package +# Traducciones al español para el paquete PACKAGE. +# Copyright (C) 2014 THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# José Carlos Cuevas , 2014. +# +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-07-14 12:21+0200\n" +"PO-Revision-Date: 2014-07-14 12:24+0100\n" +"Last-Translator: José Carlos Cuevas \n" +"Language-Team: Spanish\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Poedit 1.5.4\n" + +#: jsoninspector.py:81 +msgid "Open JSON text file" +msgstr "Abrir fichero de texto JSON" + +#: jsoninspector.py:104 +msgid "No JSON loaded." +msgstr "No se ha cargado JSON." + +#: jsoninspector.py:152 +msgid "Loaded from the clipboard." +msgstr "Cargado desde el portapapeles." + +#: jsoninspector.py:194 +msgid "Not valid JSON!\n" +msgstr "JSON no válido!\n" + +#: jsoninspector.py:210 +msgid "Not valid JSON" +msgstr "JSON no válido" + +#: jsoninspector.glade.h:1 +msgid "Enter JSON Text" +msgstr "Introduzca texto JSON" + +#: jsoninspector.glade.h:2 +msgid "JSON Inspector" +msgstr "JSON Inspector" + +#: jsoninspector.glade.h:3 +msgid "_File" +msgstr "_Archivo" + +#: jsoninspector.glade.h:4 +msgid "Cop_y JSON" +msgstr "Cop_iar JSON" + +#: jsoninspector.glade.h:5 +msgid "_Help" +msgstr "A_yuda" + +#: jsoninspector.glade.h:6 +msgid "Node" +msgstr "Nodo" + +#: jsoninspector.glade.h:7 +msgid "Value" +msgstr "Valor" + +#: jsoninspector.glade.h:8 +msgid "Type" +msgstr "Tipo" + +#: jsoninspector.glade.h:9 +msgid "No JSON loaded" +msgstr "No se ha cargado JSON" diff --git a/locale/messages.pot b/locale/messages.pot new file mode 100644 index 0000000..a26cba8 --- /dev/null +++ b/locale/messages.pot @@ -0,0 +1,74 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-07-14 12:21+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: jsoninspector.py:81 +msgid "Open JSON text file" +msgstr "" + +#: jsoninspector.py:104 +msgid "No JSON loaded." +msgstr "" + +#: jsoninspector.py:152 +msgid "Loaded from the clipboard." +msgstr "" + +#: jsoninspector.py:194 +msgid "Not valid JSON!\n" +msgstr "" + +#: jsoninspector.py:210 +msgid "Not valid JSON" +msgstr "" + +#: jsoninspector.glade.h:1 +msgid "Enter JSON Text" +msgstr "" + +#: jsoninspector.glade.h:2 +msgid "JSON Inspector" +msgstr "" + +#: jsoninspector.glade.h:3 +msgid "_File" +msgstr "" + +#: jsoninspector.glade.h:4 +msgid "Cop_y JSON" +msgstr "" + +#: jsoninspector.glade.h:5 +msgid "_Help" +msgstr "" + +#: jsoninspector.glade.h:6 +msgid "Node" +msgstr "" + +#: jsoninspector.glade.h:7 +msgid "Value" +msgstr "" + +#: jsoninspector.glade.h:8 +msgid "Type" +msgstr "" + +#: jsoninspector.glade.h:9 +msgid "No JSON loaded" +msgstr "" diff --git a/locale/po/es/LC_MESSAGES/jsoninspector.mo b/locale/po/es/LC_MESSAGES/jsoninspector.mo new file mode 100644 index 0000000000000000000000000000000000000000..9b6b1a199cc94ce3258f08ae08080bd5ec9bb089 GIT binary patch literal 1152 zcmZva&2H2%5XTLa0%`du2rBWVDHlLh%I>PDRZ0=dvMpQsv1*r!+saL*yQ$JRva>77 z8Sw(Z10ZqXg2V%G>VXp%4jhqq1tjkLodgOkR_vc=Job#8|F^RPuLas^^vme4&_~gS z4`D#-f({shHYNp6fzQE<;LE~(U#x!w2jKr)_`iT>V1EbCfj^4%!NWovg*{Yoq~Iv{ z0x?&>VXVJBBE)&{18DPp00_-6qwRx{$uytMsN5CoY64(Io3C3XaZh^wInwfJc&tdknCN!U-77K=&-9MGm#+mv>h{3uK|l+?k5SXTMAC=1zV+U0;Tq|}#D z805+RHOCyWl5m`#k|H^6h7pU_PQqecMm-koIqPUY-E*O#>%p@%8AmcyJR|H;NI_bjN4KkIn9-pThlC4Y;qsSls&4H%9Czs$}LY) zx#CsIUdf{cWp>|DP3lM)s`a=p4c*af zIK3AsUq)SJ(!1CecY3nJZj0r%M{9|UL(~1^_K1zM)L5$TU9db+a%u{{C`LZKi%0gI zZY7Zn;~Db1QX|Feqy!n%T+> z<dFPNUqX15 zjtmq9Yyu{Z$o?al$b=&{nT!lmSCU`EWwM004tg_Dsr>v{QGfRhly$&{tg0J2)KHV( eWo;AxU0o|ol$966-L7iC8}^l`ws(4g6u$r#y%Zz> literal 0 HcmV?d00001 diff --git a/src/jsoninspector.glade b/src/jsoninspector.glade index 69a574f..1d71168 100644 --- a/src/jsoninspector.glade +++ b/src/jsoninspector.glade @@ -1,10 +1,10 @@ - - + + False - Introducir texto JSON + Enter JSON Text True center 200 @@ -48,6 +48,7 @@ True True True + True @@ -65,6 +66,7 @@ True True True + True @@ -246,7 +248,7 @@ True - Nodo + Node True True 0 @@ -255,14 +257,14 @@ True - Valor + Value True True - Tipo + Type True @@ -284,7 +286,7 @@ True False - No hay JSON cargado + No JSON loaded diff --git a/src/jsoninspector.py b/src/jsoninspector.py index fd027a4..efbc4d3 100644 --- a/src/jsoninspector.py +++ b/src/jsoninspector.py @@ -2,17 +2,37 @@ # -*- coding: utf-8 -*- from pkg_resources import resource_filename +from gi.repository import Gtk, Gdk, Gio import json -from gi.repository import Gtk, Gdk, Gio +# Internationalization support +import gettext +import locale + +APP = "jsoninspector" +DIR = "po" + +locale.setlocale(locale.LC_ALL, '') + +try: + gettext.bindtextdomain(APP, DIR) + locale.bindtextdomain(APP, DIR) + +except: + gettext.bindtextdomain(APP, "../locale/") + locale.bindtextdomain(APP, "../locale/") + +gettext.textdomain(APP) +_ = gettext.gettext + class MainWindowMethods(Gtk.Application): """ Main Application object with the main window signals """ def __init__(self, logic): - Gtk.Application.__init__(self, application_id = "apps.gnome.stevedore", + Gtk.Application.__init__(self, application_id = "apps.gnome.jsoninspector", flags = Gio.ApplicationFlags.FLAGS_NONE) # We store the reference to the app logic @@ -25,6 +45,7 @@ class MainWindowMethods(Gtk.Application): Loads the MainWindow widgets, shows it up and starts the main loop """ self.builder = Gtk.Builder() + self.builder.set_translation_domain(APP) self.builder.add_from_file(resource_filename(__name__,'jsoninspector.glade')) self.builder.connect_signals(self) @@ -57,7 +78,7 @@ class MainWindowMethods(Gtk.Application): User has pressed Open in the menu """ # Create the FileChooser Dialog - chooser = Gtk.FileChooserDialog("Open JSON text file", self.window, + chooser = Gtk.FileChooserDialog(_("Open JSON text file"), self.window, Gtk.FileChooserAction.OPEN, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK)) @@ -80,7 +101,7 @@ class MainWindowMethods(Gtk.Application): else: - label.set_text("No hay JSON cargado") + label.set_text(_("No JSON loaded.")) # We finish the dialog chooser.destroy() @@ -128,7 +149,7 @@ class MainWindowMethods(Gtk.Application): if self.logicObj.loadJSONText(jsonText): status_label = self.builder.get_object("StatusLabel") - status_label.set_text("Cargado desde portapapeles.") + status_label.set_text(_("Loaded from the clipboard.")) self.logicObj.loadTree(treestore) def onCopyJSONCancelClicked(self, widget): @@ -170,7 +191,7 @@ class LogicObject(object): try: self.json = json.loads(f.read()) except ValueError: - print "JSON no válido!\n" + print _("Not valid JSON!\n") self.json = None f.close() @@ -186,7 +207,7 @@ class LogicObject(object): try: self.json = json.loads(text) except ValueError: - print "JSON no válido" + print _("Not valid JSON") self.json = None return False diff --git a/util/gen_pot.sh b/util/gen_pot.sh new file mode 100755 index 0000000..6bcfabf --- /dev/null +++ b/util/gen_pot.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +intltool-extract --type="gettext/glade" *.glade +xgettext -k_ -kN_ -o messages.pot *.py *.h +