1. Rodrigo Pinheiro Matias
  2. QSupervisorControl

Commits

Rodrigo Pinheiro Matias  committed b606975

adicionada internacionalização no projeto.

  • Participants
  • Parent commits 7fe3550
  • Branches default
  • Tags 0.2.1

Comments (0)

Files changed (6)

File .hgignore

View file
 ^(build|dist).*$
 ^.*sublime.*$
-^.*\.py(c|o)$
+^.*\.py(c|o)$
+^.*\.pot$
+^.*\.mo$

File QSupervisorControl/__init__.py

View file
 import os
 import sys
 import re
+import gettext
 
 try:
     from cStringIO import StringIO
 app_dir  = os.path.dirname(os.path.abspath(__file__))
 data_dir = os.path.join(app_dir, 'data')
 
-VERSION = '0.1.5'
+VERSION = '0.2.1'
 DEBUG = False
 # DEBUG = True
 
+gettext.bindtextdomain('base', os.path.join(data_dir, 'i18n'))
+gettext.textdomain('base')
+_ = gettext.gettext
+
 def proxy_func(func, *args, **kargs):
     def wrapper():
         func(*args, **kargs)
 
     def do_observe(self):
         translate = {
-            'STOPPED': 'Parado',
-            'RUNNING': 'Rodando',
-            'FATAL': 'Falhou'
+            'STOPPED': _('Parado'),
+            'RUNNING': _('Rodando'),
+            'FATAL': _('Falhou')
         }
 
         for program, info in self._to_observe.items():
             status = self.get_status(program)
             if status is not None:
-                info.get('action').setText(translate.get(status, 'Desconhecido'))
+                info.get('action').setText(translate.get(status, _('Desconhecido')))
                 self.changeActionIcon(info.get('menu'), status)
 
     def _createContextMenu(self):
         menu = QtGui.QMenu()
 
-        menu.addAction('Iniciar todos', proxy_func(self.do, **{'action': 'start'}))
-        menu.addAction('Parar todos', proxy_func(self.do, **{'action': 'stop'}))
-        menu.addAction('Reiniciar todos', proxy_func(self.do, **{'action': 'restart'}))
+        menu.addAction(_('Iniciar todos'), proxy_func(self.do, **{'action': 'start'}))
+        menu.addAction(_('Parar todos'), proxy_func(self.do, **{'action': 'stop'}))
+        menu.addAction(_('Reiniciar todos'), proxy_func(self.do, **{'action': 'restart'}))
 
         menu.addSeparator()
         for program in self.get_programs():
             )
 
             sub_menu.addSeparator()
-            sub_menu.addAction('Iniciar', proxy_func(self.do, **{'program': program.get('name'),'action': 'start'}))
-            sub_menu.addAction('Parar', proxy_func(self.do, **{'program': program.get('name'),'action': 'stop'}))
-            sub_menu.addAction('Reiniciar', proxy_func(self.do, **{'program': program.get('name'),'action': 'restart'}))
+            sub_menu.addAction(_('Iniciar'), proxy_func(self.do, **{'program': program.get('name'),'action': 'start'}))
+            sub_menu.addAction(_('Parar'), proxy_func(self.do, **{'program': program.get('name'),'action': 'stop'}))
+            sub_menu.addAction(_('Reiniciar'), proxy_func(self.do, **{'program': program.get('name'),'action': 'restart'}))
         menu.addSeparator()
 
         import webbrowser
 
-        sub_menu = menu.addMenu('Sobre' + (' ' * 50))
+        sub_menu = menu.addMenu(_('Sobre') + (' ' * 50))
         sub_menu.addAction(
-            u'Página do Projeto', 
+            _(u'Página do Projeto'), 
             proxy_func(
                 webbrowser.open, 
                 url = 'https://bitbucket.org/rodrigopmatias/qsupervisorcontrol/downloads'
             )
         )
-        sub_menu.addAction(u'Versão: %s' % VERSION)
+        sub_menu.addAction(u'%s: %s' % (_(u'Versão'), VERSION))
 
         if DEBUG is True:
             menu.addSeparator()
-            menu.addAction('&Finalizar' + (' ' * 50), self._app.quit)
+            menu.addAction(_('&Finalizar') + (' ' * 50), self._app.quit)
 
         return menu
 

File QSupervisorControl/data/i18n/en_US/LC_MESSAGES/base.po

View file
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR ORGANIZATION
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: QSupervisorControl\n"
+"POT-Creation-Date: 2012-07-12 23:39+BRT\n"
+"PO-Revision-Date: 2012-07-12 23:44-0300\n"
+"Last-Translator: Rodrigo Pinheiro Matias <rodrigopmatias@gmail.com>\n"
+"Language-Team: \n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Generated-By: pygettext.py 1.5\n"
+"X-Poedit-Language: Portuguese\n"
+"X-Poedit-Country: BRAZIL\n"
+"X-Poedit-SourceCharset: utf-8\n"
+
+#: QSupervisorControl/__init__.py:114
+msgid "Parado"
+msgstr "Stopped"
+
+#: QSupervisorControl/__init__.py:115
+msgid "Rodando"
+msgstr "Running"
+
+#: QSupervisorControl/__init__.py:116
+msgid "Falhou"
+msgstr "Fatal"
+
+#: QSupervisorControl/__init__.py:122
+msgid "Desconhecido"
+msgstr "Unknow"
+
+#: QSupervisorControl/__init__.py:128
+msgid "Iniciar todos"
+msgstr "Start all"
+
+#: QSupervisorControl/__init__.py:129
+msgid "Parar todos"
+msgstr "Stop all"
+
+#: QSupervisorControl/__init__.py:130
+msgid "Reiniciar todos"
+msgstr "Restart all"
+
+#: QSupervisorControl/__init__.py:142
+msgid "Iniciar"
+msgstr "Start"
+
+#: QSupervisorControl/__init__.py:143
+msgid "Parar"
+msgstr "Stop"
+
+#: QSupervisorControl/__init__.py:144
+msgid "Reiniciar"
+msgstr "Restart"
+
+#: QSupervisorControl/__init__.py:149
+msgid "Sobre"
+msgstr "About"
+
+#: QSupervisorControl/__init__.py:151
+msgid "Página do Projeto"
+msgstr "Home Page"
+
+#: QSupervisorControl/__init__.py:157
+msgid "Versão"
+msgstr "Version"
+
+#: QSupervisorControl/__init__.py:161
+msgid "&Finalizar"
+msgstr "&Close"
+

File QSupervisorControl/data/i18n/pt_BR/LC_MESSAGES/base.po

View file
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR ORGANIZATION
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: QSupervisorControl\n"
+"POT-Creation-Date: 2012-07-12 23:39+BRT\n"
+"PO-Revision-Date: 2012-07-12 23:44-0300\n"
+"Last-Translator: Rodrigo Pinheiro Matias <rodrigopmatias@gmail.com>\n"
+"Language-Team: \n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Generated-By: pygettext.py 1.5\n"
+"X-Poedit-Language: Portuguese\n"
+"X-Poedit-Country: BRAZIL\n"
+"X-Poedit-SourceCharset: utf-8\n"
+
+#: QSupervisorControl/__init__.py:114
+msgid "Parado"
+msgstr "Parado"
+
+#: QSupervisorControl/__init__.py:115
+msgid "Rodando"
+msgstr "Rodando"
+
+#: QSupervisorControl/__init__.py:116
+msgid "Falhou"
+msgstr "Falhou"
+
+#: QSupervisorControl/__init__.py:122
+msgid "Desconhecido"
+msgstr "Desconhecido"
+
+#: QSupervisorControl/__init__.py:128
+msgid "Iniciar todos"
+msgstr "Iniciar todos"
+
+#: QSupervisorControl/__init__.py:129
+msgid "Parar todos"
+msgstr "Parar todos"
+
+#: QSupervisorControl/__init__.py:130
+msgid "Reiniciar todos"
+msgstr "Reiniciar todos"
+
+#: QSupervisorControl/__init__.py:142
+msgid "Iniciar"
+msgstr "Iniciar"
+
+#: QSupervisorControl/__init__.py:143
+msgid "Parar"
+msgstr "Parar"
+
+#: QSupervisorControl/__init__.py:144
+msgid "Reiniciar"
+msgstr "Reiniciar"
+
+#: QSupervisorControl/__init__.py:149
+msgid "Sobre"
+msgstr "Sobre"
+
+#: QSupervisorControl/__init__.py:151
+msgid "Página do Projeto"
+msgstr "Página do Projeto"
+
+#: QSupervisorControl/__init__.py:157
+msgid "Versão"
+msgstr "Versão"
+
+#: QSupervisorControl/__init__.py:161
+msgid "&Finalizar"
+msgstr "&Finalizar"
+

File VERSION.txt

View file
-0.1.4
+0.2.1

File setup.py

View file
 from distutils.core import setup
 from QSupervisorControl import VERSION
 
+import os
+
+def get_locales():
+    i18n_dir = os.path.join(
+        os.path.dirname(os.path.abspath(__file__)), 
+        'QSupervisorControl',
+        'data',
+        'i18n'
+    )
+    locale_file = lambda x: os.path.join('data', 'i18n', x, 'LC_MESSAGES/*.mo')
+    test = lambda x: os.path.isdir(os.path.join(i18n_dir, x))
+    rst = [locale_file(filename) for filename in os.listdir(i18n_dir) if test(filename) is True]
+    return rst
+
 setup(
     name = 'QSupervisorControl',
     description = 'The simples tray system that observe status of services managed with supervisor.',
     scripts = ['QSupervisorControl.py'],
     install_requires = ['supervisor'],
     packages = ['QSupervisorControl'],
-    package_data = {'QSupervisorControl': ['data/*.png']}
+    package_data = {'QSupervisorControl': ['data/*.png'] + get_locales()}
 )