diff --git a/locale/es.mo b/locale/es.mo new file mode 100644 index 0000000..9b6b1a1 Binary files /dev/null and b/locale/es.mo differ 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 0000000..9b6b1a1 Binary files /dev/null and b/locale/po/es/LC_MESSAGES/jsoninspector.mo differ 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 +