Add spanish
This commit is contained in:
parent
7bfaafcbfa
commit
939c6d54bd
4
conf.py
4
conf.py
|
@ -26,7 +26,7 @@ import logging
|
|||
TYPE_EXTENSION = 1
|
||||
|
||||
# ~ https://semver.org/
|
||||
VERSION = '0.1.0'
|
||||
VERSION = '0.2.0'
|
||||
|
||||
# ~ Your great extension name, not used spaces
|
||||
NAME = 'ZAZPip'
|
||||
|
@ -207,6 +207,8 @@ PATHS = {
|
|||
'soffice': ('soffice', PROGRAM, FILE_TEST),
|
||||
'install': ('unopkg', 'add', '-v', '-f', '-s'),
|
||||
'profile': '/home/mau/.config/libreoffice/4/user',
|
||||
'gettext': PATH_PYGETTEXT,
|
||||
'msgmerge': PATH_MSGMERGE,
|
||||
}
|
||||
|
||||
|
||||
|
|
17
easymacro.py
17
easymacro.py
|
@ -22,6 +22,7 @@ import csv
|
|||
import ctypes
|
||||
import datetime
|
||||
import errno
|
||||
import gettext
|
||||
import getpass
|
||||
import hashlib
|
||||
import json
|
||||
|
@ -100,6 +101,7 @@ ID_EXTENSION = ''
|
|||
|
||||
DIR = {
|
||||
'images': 'images',
|
||||
'locales': 'locales',
|
||||
}
|
||||
|
||||
KEY = {
|
||||
|
@ -4665,6 +4667,7 @@ def import_csv(path, **kwargs):
|
|||
rows = tuple(csv.reader(f, **kwargs))
|
||||
return rows
|
||||
|
||||
|
||||
def export_csv(path, data, **kwargs):
|
||||
with open(path, 'w') as f:
|
||||
writer = csv.writer(f, **kwargs)
|
||||
|
@ -4672,6 +4675,20 @@ def export_csv(path, data, **kwargs):
|
|||
return
|
||||
|
||||
|
||||
@catch_exception
|
||||
def install_locales(path, domain='base', dir_locales=DIR['locales']):
|
||||
p, *_ = get_info_path(path)
|
||||
path_locales = join(p, dir_locales)
|
||||
try:
|
||||
lang = gettext.translation(domain, path_locales, languages=[LANG])
|
||||
lang.install()
|
||||
_ = lang.gettext
|
||||
except Exception as e:
|
||||
from gettext import gettext as _
|
||||
error(e)
|
||||
return _
|
||||
|
||||
|
||||
class LIBOServer(object):
|
||||
HOST = 'localhost'
|
||||
PORT = '8100'
|
||||
|
|
Binary file not shown.
|
@ -1,10 +1,8 @@
|
|||
import uno
|
||||
import unohelper
|
||||
import os
|
||||
from com.sun.star.task import XJobExecutor
|
||||
import easymacro as app
|
||||
|
||||
import site
|
||||
|
||||
ID_EXTENSION = 'net.elmau.zaz.pip'
|
||||
SERVICE = ('com.sun.star.task.Job',)
|
||||
|
@ -21,11 +19,7 @@ PACKAGES = {
|
|||
}
|
||||
|
||||
|
||||
# ~ sudoPassword = 'mypass'
|
||||
# ~ command = 'mount -t vboxsf myfolder /home/myuser/myfolder'.split()
|
||||
# ~ cmd1 = subprocess.Popen(['echo',sudoPassword], stdout=subprocess.PIPE)
|
||||
# ~ cmd2 = subprocess.Popen(['sudo','-S'] + command, stdin=cmd1.stdout, stdout=subprocess.PIPE)
|
||||
# ~ output = cmd2.stdout.read.decode()
|
||||
_ = app.install_locales(__file__)
|
||||
|
||||
|
||||
class Controllers(object):
|
||||
|
@ -254,13 +248,13 @@ class Controllers(object):
|
|||
def cmd_shell_action(self, name):
|
||||
if app.IS_WIN:
|
||||
cmd = '"{}"'.format(self.path_python)
|
||||
os.startfile(cmd)
|
||||
app.open_file(cmd)
|
||||
else:
|
||||
if app.DESKTOP == 'gnome':
|
||||
cmd = 'gnome-terminal -- {}'.format(self.path_python)
|
||||
else:
|
||||
cmd = 'exec {}'.format(self.path_python)
|
||||
os.system(cmd)
|
||||
app.run(cmd)
|
||||
return
|
||||
|
||||
|
||||
|
@ -277,7 +271,7 @@ class ZAZPip(unohelper.Base, XJobExecutor):
|
|||
def _create_dialog(self):
|
||||
args= {
|
||||
'Name': 'dialog',
|
||||
'Title': 'ZAZ-Pip',
|
||||
'Title': 'ZAZ-PIP',
|
||||
'Width': 200,
|
||||
'Height': 220,
|
||||
}
|
||||
|
@ -288,7 +282,7 @@ class ZAZPip(unohelper.Base, XJobExecutor):
|
|||
args = {
|
||||
'Type': 'Label',
|
||||
'Name': 'lbl_title',
|
||||
'Label': 'ZAZ Pip',
|
||||
'Label': 'ZAZ PIP',
|
||||
'Width': 50,
|
||||
'Height': 15,
|
||||
'Border': 1,
|
||||
|
@ -330,7 +324,7 @@ class ZAZPip(unohelper.Base, XJobExecutor):
|
|||
exists_pip = True
|
||||
if not label:
|
||||
exists_pip = False
|
||||
label = 'PIP not installed'
|
||||
label = _('PIP not installed')
|
||||
args = {
|
||||
'Type': 'Label',
|
||||
'Name': 'lbl_pip',
|
||||
|
@ -349,7 +343,7 @@ class ZAZPip(unohelper.Base, XJobExecutor):
|
|||
args = {
|
||||
'Type': 'Button',
|
||||
'Name': 'cmd_admin_pip',
|
||||
'Label': 'Admin PIP',
|
||||
'Label': _('Admin PIP'),
|
||||
'Width': 60,
|
||||
'Height': 18,
|
||||
'Step': 10,
|
||||
|
@ -362,7 +356,7 @@ class ZAZPip(unohelper.Base, XJobExecutor):
|
|||
args = {
|
||||
'Type': 'Button',
|
||||
'Name': 'cmd_install_pip',
|
||||
'Label': 'Install PIP',
|
||||
'Label': _('Install PIP'),
|
||||
'Width': 60,
|
||||
'Height': 18,
|
||||
'Step': 10,
|
||||
|
@ -400,7 +394,7 @@ class ZAZPip(unohelper.Base, XJobExecutor):
|
|||
args = {
|
||||
'Type': 'Label',
|
||||
'Name': 'lbl_package',
|
||||
'Label': 'Packages',
|
||||
'Label': _('Packages'),
|
||||
'Width': 100,
|
||||
'Height': 15,
|
||||
'Border': 1,
|
||||
|
@ -432,7 +426,7 @@ class ZAZPip(unohelper.Base, XJobExecutor):
|
|||
args = {
|
||||
'Type': 'Button',
|
||||
'Name': 'cmd_close',
|
||||
'Label': '~Close',
|
||||
'Label': _('~Close'),
|
||||
'Width': 60,
|
||||
'Height': 18,
|
||||
'Step': 1,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<description xmlns="http://openoffice.org/extensions/description/2006" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:d="http://openoffice.org/extensions/description/2006">
|
||||
<identifier value="net.elmau.zaz.pip" />
|
||||
<version value="0.1.0" />
|
||||
<version value="0.2.0" />
|
||||
<display-name>
|
||||
<name lang="en">ZAZ Pip</name>
|
||||
<name lang="es">ZAZ Pip</name>
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR ORGANIZATION
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2019-10-19 14:42-0500\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\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"
|
||||
|
||||
|
||||
#: source/ZAZPip.py:327
|
||||
msgid "PIP not installed"
|
||||
msgstr ""
|
||||
|
||||
#: source/ZAZPip.py:346
|
||||
msgid "Admin PIP"
|
||||
msgstr ""
|
||||
|
||||
#: source/ZAZPip.py:359
|
||||
msgid "Install PIP"
|
||||
msgstr ""
|
||||
|
||||
#: source/ZAZPip.py:397
|
||||
msgid "Packages"
|
||||
msgstr ""
|
||||
|
||||
#: source/ZAZPip.py:429
|
||||
msgid "~Close"
|
||||
msgstr ""
|
||||
|
Binary file not shown.
|
@ -0,0 +1,38 @@
|
|||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR ORGANIZATION
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"POT-Creation-Date: 2019-10-19 14:42-0500\n"
|
||||
"PO-Revision-Date: 2019-10-19 15:13-0500\n"
|
||||
"Language-Team: \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-Generator: Poedit 2.2.4\n"
|
||||
"Last-Translator: \n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
"Language: en\n"
|
||||
|
||||
#: source/ZAZPip.py:327
|
||||
msgid "PIP not installed"
|
||||
msgstr "PIP not installed"
|
||||
|
||||
#: source/ZAZPip.py:346
|
||||
msgid "Admin PIP"
|
||||
msgstr "Admin PIP"
|
||||
|
||||
#: source/ZAZPip.py:359
|
||||
msgid "Install PIP"
|
||||
msgstr "Install PIP"
|
||||
|
||||
#: source/ZAZPip.py:397
|
||||
msgid "Packages"
|
||||
msgstr "Packages"
|
||||
|
||||
#: source/ZAZPip.py:429
|
||||
msgid "~Close"
|
||||
msgstr "~Close"
|
Binary file not shown.
|
@ -0,0 +1,38 @@
|
|||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR ORGANIZATION
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"POT-Creation-Date: 2019-10-19 14:42-0500\n"
|
||||
"PO-Revision-Date: 2019-10-19 15:14-0500\n"
|
||||
"Language-Team: \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-Generator: Poedit 2.2.4\n"
|
||||
"Last-Translator: \n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
"Language: es\n"
|
||||
|
||||
#: source/ZAZPip.py:327
|
||||
msgid "PIP not installed"
|
||||
msgstr "PIP no esta instalado"
|
||||
|
||||
#: source/ZAZPip.py:346
|
||||
msgid "Admin PIP"
|
||||
msgstr "Administrar PIP"
|
||||
|
||||
#: source/ZAZPip.py:359
|
||||
msgid "Install PIP"
|
||||
msgstr "Instalar PIP"
|
||||
|
||||
#: source/ZAZPip.py:397
|
||||
msgid "Packages"
|
||||
msgstr "Paquetes"
|
||||
|
||||
#: source/ZAZPip.py:429
|
||||
msgid "~Close"
|
||||
msgstr "~Cerrar"
|
|
@ -22,6 +22,7 @@ import csv
|
|||
import ctypes
|
||||
import datetime
|
||||
import errno
|
||||
import gettext
|
||||
import getpass
|
||||
import hashlib
|
||||
import json
|
||||
|
@ -100,6 +101,7 @@ ID_EXTENSION = ''
|
|||
|
||||
DIR = {
|
||||
'images': 'images',
|
||||
'locales': 'locales',
|
||||
}
|
||||
|
||||
KEY = {
|
||||
|
@ -4665,6 +4667,7 @@ def import_csv(path, **kwargs):
|
|||
rows = tuple(csv.reader(f, **kwargs))
|
||||
return rows
|
||||
|
||||
|
||||
def export_csv(path, data, **kwargs):
|
||||
with open(path, 'w') as f:
|
||||
writer = csv.writer(f, **kwargs)
|
||||
|
@ -4672,6 +4675,20 @@ def export_csv(path, data, **kwargs):
|
|||
return
|
||||
|
||||
|
||||
@catch_exception
|
||||
def install_locales(path, domain='base', dir_locales=DIR['locales']):
|
||||
p, *_ = get_info_path(path)
|
||||
path_locales = join(p, dir_locales)
|
||||
try:
|
||||
lang = gettext.translation(domain, path_locales, languages=[LANG])
|
||||
lang.install()
|
||||
_ = lang.gettext
|
||||
except Exception as e:
|
||||
from gettext import gettext as _
|
||||
error(e)
|
||||
return _
|
||||
|
||||
|
||||
class LIBOServer(object):
|
||||
HOST = 'localhost'
|
||||
PORT = '8100'
|
||||
|
|
60
zaz.py
60
zaz.py
|
@ -33,6 +33,7 @@ from xml.dom.minidom import parseString
|
|||
from conf import (
|
||||
DATA,
|
||||
DIRS,
|
||||
DOMAIN,
|
||||
EXTENSION,
|
||||
FILES,
|
||||
INFO,
|
||||
|
@ -138,6 +139,19 @@ def _save(path, data):
|
|||
return
|
||||
|
||||
|
||||
def _get_files(path, filters=''):
|
||||
paths = []
|
||||
if filters in ('*', '*.*'):
|
||||
filters = ''
|
||||
for folder, _, files in os.walk(path):
|
||||
if filters:
|
||||
pattern = re.compile(r'\.(?:{})$'.format(filters), re.IGNORECASE)
|
||||
paths += [_join(folder, f) for f in files if pattern.search(f)]
|
||||
else:
|
||||
paths += files
|
||||
return paths
|
||||
|
||||
|
||||
def _compress_oxt():
|
||||
log.info('Compress OXT extension...')
|
||||
|
||||
|
@ -435,8 +449,50 @@ def _embed(args):
|
|||
return
|
||||
|
||||
|
||||
def _locales(args):
|
||||
EASYMACRO = 'easymacro.py'
|
||||
|
||||
if args.files:
|
||||
files = args.files.split(',')
|
||||
else:
|
||||
files = _get_files(DIRS['source'], 'py')
|
||||
paths = ' '.join([f for f in files if not EASYMACRO in f])
|
||||
path_pot = _join(DIRS['source'], DIRS['locales'], '{}.pot'.format(DOMAIN))
|
||||
call([PATHS['gettext'], '-o', path_pot, paths])
|
||||
log.info('POT generate successfully...')
|
||||
return
|
||||
|
||||
|
||||
def _update():
|
||||
path_locales = _join(DIRS['source'], DIRS['locales'])
|
||||
path_pot = _join(DIRS['source'], DIRS['locales'], '{}.pot'.format(DOMAIN))
|
||||
if not _exists(path_pot):
|
||||
log.error('Not exists file POT...')
|
||||
return
|
||||
|
||||
files = _get_files(path_locales, 'po')
|
||||
if not files:
|
||||
log.error('First, generate files PO...')
|
||||
return
|
||||
|
||||
for f in files:
|
||||
call([PATHS['msgmerge'], '-U', f, path_pot])
|
||||
log.info('\tUpdate: {}'.format(f))
|
||||
|
||||
log.info('Locales update successfully...')
|
||||
return
|
||||
|
||||
|
||||
|
||||
def main(args):
|
||||
if args.update:
|
||||
_update()
|
||||
return
|
||||
|
||||
if args.locales:
|
||||
_locales(args)
|
||||
return
|
||||
|
||||
if args.embed:
|
||||
_embed(args)
|
||||
return
|
||||
|
@ -469,6 +525,10 @@ def _process_command_line_arguments():
|
|||
default=False, required=False)
|
||||
parser.add_argument('-d', '--document', dest='document', default='')
|
||||
parser.add_argument('-f', '--files', dest='files', default='')
|
||||
parser.add_argument('-l', '--locales', dest='locales', action='store_true',
|
||||
default=False, required=False)
|
||||
parser.add_argument('-u', '--update', dest='update', action='store_true',
|
||||
default=False, required=False)
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue