From 2647398fddcd4e949183c29e0b5f3bf8a1c3d738 Mon Sep 17 00:00:00 2001 From: "Leonardo J. Caballero G" Date: Wed, 8 Jan 2020 08:49:13 -0400 Subject: [PATCH] Added improvements about i18n support #1 --- opencore/cabochon/client.py | 9 ++-- opencore/cabochon/configure.zcml | 6 ++- .../locales/en/LC_MESSAGES/opencore.po | 33 ++++++++++++++ .../locales/es/LC_MESSAGES/opencore.po | 43 +++++++++++++++++++ opencore/cabochon/locales/opencore.pot | 34 +++++++++++++++ opencore/cabochon/locales/rebuild_i18n | 24 +++++++++++ 6 files changed, 144 insertions(+), 5 deletions(-) create mode 100644 opencore/cabochon/locales/en/LC_MESSAGES/opencore.po create mode 100644 opencore/cabochon/locales/es/LC_MESSAGES/opencore.po create mode 100644 opencore/cabochon/locales/opencore.pot create mode 100755 opencore/cabochon/locales/rebuild_i18n diff --git a/opencore/cabochon/client.py b/opencore/cabochon/client.py index 1995300..1c93d26 100644 --- a/opencore/cabochon/client.py +++ b/opencore/cabochon/client.py @@ -2,6 +2,7 @@ from datetime import datetime from opencore.cabochon.interfaces import ICabochonClient from opencore.configuration.utils import product_config +from opencore.i18n import _ from opencore.utility.interfaces import IProvideSiteConfig from threading import Thread, Lock from zope.interface import implements @@ -23,20 +24,20 @@ def __init__(self): cabochon_user_info_file = product_config('cabochon_user_info', 'opencore.nui') if not cabochon_user_info_file: - raise CabochonConfigError('no cabochon_user_info file specified in zope.conf opencore.nui') + raise CabochonConfigError(_(u"no cabochon_user_info file specified in zope.conf opencore.nui")) try: f = open(cabochon_user_info_file) username, password = f.read().strip().split(':', 1) f.close() except IOError: - raise CabochonConfigError('bad cabochon_user_info file specified in zope.conf opencore.nui') + raise CabochonConfigError(_(u"bad cabochon_user_info file specified in zope.conf opencore.nui")) # get cabochon_messages filesystem location from configuration cabochon_messages_dir = product_config('cabochon_messages', 'opencore.nui') if not cabochon_messages_dir: - raise CabochonConfigError('no cabochon_messages directory specified in zope.conf opencore.nui') + raise CabochonConfigError(_(u"no cabochon_messages directory specified in zope.conf opencore.nui")) # Stash config settings for later. self.cabochon_messages_dir = cabochon_messages_dir @@ -80,7 +81,7 @@ def cabochon_uri(self): cabochon_uri = getUtility(IProvideSiteConfig).get('cabochon uri') cabochon_uri = cabochon_uri.strip() if not cabochon_uri: - raise CabochonConfigError('invalid empty cabochon uri or cabochon uri not set') + raise CabochonConfigError(_(u"invalid empty cabochon uri or cabochon uri not set")) return cabochon_uri def notify_project_created(self, id, creatorid): diff --git a/opencore/cabochon/configure.zcml b/opencore/cabochon/configure.zcml index 0b29c07..005141f 100644 --- a/opencore/cabochon/configure.zcml +++ b/opencore/cabochon/configure.zcml @@ -1,4 +1,8 @@ - + + + \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=1; plural=0\n" +"Language-Code: en\n" +"Language-Name: English\n" +"Preferred-Encodings: utf-8 latin1\n" +"Domain: opencore\n" +"X-Poedit-Language: English\n" +"X-Poedit-Country: UNITED STATES\n" + +#: ../client.py:34 +msgid "bad cabochon_user_info file specified in zope.conf opencore.nui" +msgstr "" + +#: ../client.py:84 +msgid "invalid empty cabochon uri or cabochon uri not set" +msgstr "" + +#: ../client.py:40 +msgid "no cabochon_messages directory specified in zope.conf opencore.nui" +msgstr "" + +#: ../client.py:27 +msgid "no cabochon_user_info file specified in zope.conf opencore.nui" +msgstr "" diff --git a/opencore/cabochon/locales/es/LC_MESSAGES/opencore.po b/opencore/cabochon/locales/es/LC_MESSAGES/opencore.po new file mode 100644 index 0000000..e226fb1 --- /dev/null +++ b/opencore/cabochon/locales/es/LC_MESSAGES/opencore.po @@ -0,0 +1,43 @@ +# Gettext Message File for Spanish translation of opencore domain using on opencore.cabochon package +# Translators: +# Leonardo J. Caballero G. , 2020. +msgid "" +msgstr "" +"Project-Id-Version: opencore\n" +"POT-Creation-Date: 2020-01-08 02:28+0000\n" +"PO-Revision-Date: 2020-01-07 22:34-0400\n" +"Last-Translator: Leonardo J. Caballero G. \n" +"Language-Team: ES \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: Virtaal 0.7.1\n" +"Language-Code: es\n" +"Language-Name: Español\n" +"Preferred-Encodings: utf-8 latin1\n" +"Domain: opencore\n" +"X-Is-Fallback-For: es-ar es-bo es-cl es-co es-cr es-do es-ec es-es es-sv es-gt es-hn es-mx es-ni es-pa es-py es-pe es-pr es-us es-uy es-ve\n" + +#: ../client.py:34 +msgid "bad cabochon_user_info file specified in zope.conf opencore.nui" +msgstr "" +"mal archivo cabochon_user_info especificado en el archivo zope.conf " +"opencore.nui" + +#: ../client.py:84 +msgid "invalid empty cabochon uri or cabochon uri not set" +msgstr "uri del cabochon vacío no válido o uri del cabochon no establecido" + +#: ../client.py:40 +msgid "no cabochon_messages directory specified in zope.conf opencore.nui" +msgstr "" +"no se especificó el directorio cabochon_messages en el archivo zope.conf " +"opencore.nui" + +#: ../client.py:27 +msgid "no cabochon_user_info file specified in zope.conf opencore.nui" +msgstr "" +"no se especificó el archivo cabochon_user_info en el archivo zope.conf " +"opencore.nui" diff --git a/opencore/cabochon/locales/opencore.pot b/opencore/cabochon/locales/opencore.pot new file mode 100644 index 0000000..79422db --- /dev/null +++ b/opencore/cabochon/locales/opencore.pot @@ -0,0 +1,34 @@ +# --- PLEASE EDIT THE LINES BELOW CORRECTLY --- +# SOME DESCRIPTIVE TITLE. +# FIRST AUTHOR , YEAR. +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"POT-Creation-Date: 2020-01-08 02:28+0000\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=1; plural=0\n" +"Language-Code: en\n" +"Language-Name: English\n" +"Preferred-Encodings: utf-8 latin1\n" +"Domain: opencore\n" + +#: ../client.py:34 +msgid "bad cabochon_user_info file specified in zope.conf opencore.nui" +msgstr "" + +#: ../client.py:84 +msgid "invalid empty cabochon uri or cabochon uri not set" +msgstr "" + +#: ../client.py:40 +msgid "no cabochon_messages directory specified in zope.conf opencore.nui" +msgstr "" + +#: ../client.py:27 +msgid "no cabochon_user_info file specified in zope.conf opencore.nui" +msgstr "" diff --git a/opencore/cabochon/locales/rebuild_i18n b/opencore/cabochon/locales/rebuild_i18n new file mode 100755 index 0000000..513cafe --- /dev/null +++ b/opencore/cabochon/locales/rebuild_i18n @@ -0,0 +1,24 @@ +domain='opencore' + +# Synchronise the templates and scripts with the .pot file for opencore domain. +i18ndude rebuild-pot --pot ./$domain.pot --create $domain ../ + +# Synchronise the opencore's pot file (Used for the workflows) +i18ndude sync --pot ./$domain.pot ./*/LC_MESSAGES/$domain.po + +WARNINGS=`find . -name "*pt" | xargs i18ndude find-untranslated | grep -e '^-WARN' | wc -l` +ERRORS=`find . -name "*pt" | xargs i18ndude find-untranslated | grep -e '^-ERROR' | wc -l` +FATAL=`find . -name "*pt" | xargs i18ndude find-untranslated | grep -e '^-FATAL' | wc -l` + +echo +echo "There are $WARNINGS warnings \(possibly missing i18n markup\)" +echo "There are $ERRORS errors \(almost definitely missing i18n markup\)" +echo "There are $FATAL fatal errors \(template could not be parsed, eg. if it\'s not html\)" +echo "For more details, run \'find . -name \"\*pt\" \| xargs i18ndude find-untranslated\' or" +echo "Look the rebuild i18n log generate for this script called \'rebuild_i18n.log\' on locales dir" + +rm ./rebuild_i18n.log + +touch ./rebuild_i18n.log + +find ../ -name "*pt" | xargs i18ndude find-untranslated > rebuild_i18n.log