Skip to content

Commit

Permalink
Added improvements about i18n support #1
Browse files Browse the repository at this point in the history
  • Loading branch information
macagua committed Jan 8, 2020
1 parent ad87cf3 commit 2647398
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 5 deletions.
9 changes: 5 additions & 4 deletions opencore/cabochon/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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):
Expand Down
6 changes: 5 additions & 1 deletion opencore/cabochon/configure.zcml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<configure xmlns="http://namespaces.zope.org/zope">
<configure xmlns="http://namespaces.zope.org/zope"
xmlns:i18n="http://namespaces.zope.org/i18n"
i18n_domain="opencore">

<i18n:registerTranslations directory="locales">

<utility
factory="opencore.cabochon.client.CabochonUtility"
Expand Down
33 changes: 33 additions & 0 deletions opencore/cabochon/locales/en/LC_MESSAGES/opencore.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
msgid ""
msgstr ""
"Project-Id-Version: opencore\n"
"POT-Creation-Date: 2020-01-08 02:28+0000\n"
"PO-Revision-Date: 2008-10-08 15:57-0400\n"
"Last-Translator: \n"
"Language-Team: The Open Planning Project <[email protected]>\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 ""
43 changes: 43 additions & 0 deletions opencore/cabochon/locales/es/LC_MESSAGES/opencore.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Gettext Message File for Spanish translation of opencore domain using on opencore.cabochon package
# Translators:
# Leonardo J. Caballero G. <[email protected]>, 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. <[email protected]>\n"
"Language-Team: ES <[email protected]>\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"
34 changes: 34 additions & 0 deletions opencore/cabochon/locales/opencore.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# --- PLEASE EDIT THE LINES BELOW CORRECTLY ---
# SOME DESCRIPTIVE TITLE.
# FIRST AUTHOR <EMAIL@ADDRESS>, 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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\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 ""
24 changes: 24 additions & 0 deletions opencore/cabochon/locales/rebuild_i18n
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 2647398

Please sign in to comment.