Skip to content

Commit

Permalink
Added more 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 2bea7e1 commit c9910fa
Show file tree
Hide file tree
Showing 8 changed files with 335 additions and 9 deletions.
2 changes: 2 additions & 0 deletions unweb/trusted/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
xmlns:browser="http://namespaces.zope.org/browser"
i18n_domain="unweb.trusted">

<i18n:registerTranslations directory="locales" />

<five:registerPackage package="." initialize=".initialize" />
<include file="permissions.zcml" />

Expand Down
95 changes: 95 additions & 0 deletions unweb/trusted/locales/en/LC_MESSAGES/opencore.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
msgid ""
msgstr ""
"Project-Id-Version: opencore\n"
"POT-Creation-Date: 2020-01-08 23:11+0000\n"
"PO-Revision-Date: 2008-10-08 15:57-0400\n"
"Last-Translator: \n"
"Language-Team: The Open Planning Project <opencore-dev@lists.openplans.org>\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"

#: ../subscribe_members.pt:17
msgid "(enter e-mail addresses or usernames; use commas or newlines to separate;)"
msgstr ""

#: ../subscribe_members.pt:25
msgid "Cancel"
msgstr ""

#: ../manage_membership.pt:49
msgid "Contact"
msgstr ""

#. Default: "Contact (email)"
#: ../manage_membership.pt:53
msgid "Contact_email"
msgstr ""

#: ../subscribe_members.pt:16
msgid "Emails:"
msgstr ""

#: ../manage_membership.pt:82
msgid "Save changes"
msgstr ""

#: ../subscribe_members.pt:24
msgid "Subscribe"
msgstr ""

#: ../subscribe_members.pt:10
msgid "Subscribe members"
msgstr ""

#. Default: "Add:"
#: ../manage_membership.pt:66
msgid "manage_membership_add"
msgstr ""

#. Default: "Added: ${added}"
#: ../manage_membership.py:72
msgid "manage_membership_added_msg"
msgstr ""

#. Default: "Bad user or email address: ${errors}"
#: ../manage_membership.py:67
msgid "manage_membership_bad_user_email_msg"
msgstr ""

#. Default: "<br />Use the above form to add allowed senders or to invite new mailing list members. Since you are a trusted list admin on openfsm.net you can instead ${subscribe_members_directly} without requiring their email confirmation. Please use with caution and only if certain that the user will not object."
#: ../manage_membership.pt:87
msgid "manage_membership_can_subscribe_others"
msgstr ""

#. Default: "Remove"
#: ../manage_membership.pt:20
msgid "manage_membership_remove"
msgstr ""

#. Default: "Subscribe?"
#: ../manage_membership.pt:71
msgid "manage_membership_subscribe"
msgstr ""

#. Default: "subscribe new members directly"
#: ../manage_membership.pt:87
msgid "manage_membership_subscribe_members_directly"
msgstr ""

#. Default: "Subscribed"
#: ../manage_membership.pt:22
msgid "manage_membership_subscribed"
msgstr ""

#. Default: "Address / User ID"
#: ../manage_membership.pt:21
msgid "manage_membership_user"
msgstr ""
99 changes: 99 additions & 0 deletions unweb/trusted/locales/es/LC_MESSAGES/opencore.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Gettext Message File for Spanish translation of opencore domain using on unweb.trusted package
# Translators:
# Leonardo J. Caballero G. <leonardocaballero@gmail.com>, 2020.
msgid ""
msgstr ""
"Project-Id-Version: opencore\n"
"POT-Creation-Date: 2020-01-08 23:11+0000\n"
"PO-Revision-Date: 2020-01-07 22:34-0400\n"
"Last-Translator: Leonardo J. Caballero G. <leonardocaballero@gmail.com>\n"
"Language-Team: ES <LL@li.org>\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"
"Language-Code: es\n"
"Language-Name: Español\n"
"Preferred-Encodings: utf-8 latin1\n"
"Domain: opencore\n"
"Language: es\n"
"X-Generator: Virtaal 0.7.1\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"

#: ../subscribe_members.pt:17
msgid "(enter e-mail addresses or usernames; use commas or newlines to separate;)"
msgstr ""

#: ../subscribe_members.pt:25
msgid "Cancel"
msgstr ""

#: ../manage_membership.pt:49
msgid "Contact"
msgstr ""

#. Default: "Contact (email)"
#: ../manage_membership.pt:53
msgid "Contact_email"
msgstr ""

#: ../subscribe_members.pt:16
msgid "Emails:"
msgstr ""

#: ../manage_membership.pt:82
msgid "Save changes"
msgstr ""

#: ../subscribe_members.pt:24
msgid "Subscribe"
msgstr ""

#: ../subscribe_members.pt:10
msgid "Subscribe members"
msgstr ""

#. Default: "Add:"
#: ../manage_membership.pt:66
msgid "manage_membership_add"
msgstr ""

#. Default: "Added: ${added}"
#: ../manage_membership.py:72
msgid "manage_membership_added_msg"
msgstr ""

#. Default: "Bad user or email address: ${errors}"
#: ../manage_membership.py:67
msgid "manage_membership_bad_user_email_msg"
msgstr ""

#. Default: "<br />Use the above form to add allowed senders or to invite new mailing list members. Since you are a trusted list admin on openfsm.net you can instead ${subscribe_members_directly} without requiring their email confirmation. Please use with caution and only if certain that the user will not object."
#: ../manage_membership.pt:87
msgid "manage_membership_can_subscribe_others"
msgstr ""

#. Default: "Remove"
#: ../manage_membership.pt:20
msgid "manage_membership_remove"
msgstr ""

#. Default: "Subscribe?"
#: ../manage_membership.pt:71
msgid "manage_membership_subscribe"
msgstr ""

#. Default: "subscribe new members directly"
#: ../manage_membership.pt:87
msgid "manage_membership_subscribe_members_directly"
msgstr ""

#. Default: "Subscribed"
#: ../manage_membership.pt:22
msgid "manage_membership_subscribed"
msgstr ""

#. Default: "Address / User ID"
#: ../manage_membership.pt:21
msgid "manage_membership_user"
msgstr ""
96 changes: 96 additions & 0 deletions unweb/trusted/locales/opencore.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# --- 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 23:11+0000\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"
"Plural-Forms: nplurals=1; plural=0\n"
"Language-Code: en\n"
"Language-Name: English\n"
"Preferred-Encodings: utf-8 latin1\n"
"Domain: opencore\n"

#: ../subscribe_members.pt:17
msgid "(enter e-mail addresses or usernames; use commas or newlines to separate;)"
msgstr ""

#: ../subscribe_members.pt:25
msgid "Cancel"
msgstr ""

#: ../manage_membership.pt:49
msgid "Contact"
msgstr ""

#. Default: "Contact (email)"
#: ../manage_membership.pt:53
msgid "Contact_email"
msgstr ""

#: ../subscribe_members.pt:16
msgid "Emails:"
msgstr ""

#: ../manage_membership.pt:82
msgid "Save changes"
msgstr ""

#: ../subscribe_members.pt:24
msgid "Subscribe"
msgstr ""

#: ../subscribe_members.pt:10
msgid "Subscribe members"
msgstr ""

#. Default: "Add:"
#: ../manage_membership.pt:66
msgid "manage_membership_add"
msgstr ""

#. Default: "Added: ${added}"
#: ../manage_membership.py:72
msgid "manage_membership_added_msg"
msgstr ""

#. Default: "Bad user or email address: ${errors}"
#: ../manage_membership.py:67
msgid "manage_membership_bad_user_email_msg"
msgstr ""

#. Default: "<br />Use the above form to add allowed senders or to invite new mailing list members. Since you are a trusted list admin on openfsm.net you can instead ${subscribe_members_directly} without requiring their email confirmation. Please use with caution and only if certain that the user will not object."
#: ../manage_membership.pt:87
msgid "manage_membership_can_subscribe_others"
msgstr ""

#. Default: "Remove"
#: ../manage_membership.pt:20
msgid "manage_membership_remove"
msgstr ""

#. Default: "Subscribe?"
#: ../manage_membership.pt:71
msgid "manage_membership_subscribe"
msgstr ""

#. Default: "subscribe new members directly"
#: ../manage_membership.pt:87
msgid "manage_membership_subscribe_members_directly"
msgstr ""

#. Default: "Subscribed"
#: ../manage_membership.pt:22
msgid "manage_membership_subscribed"
msgstr ""

#. Default: "Address / User ID"
#: ../manage_membership.pt:21
msgid "manage_membership_user"
msgstr ""
27 changes: 27 additions & 0 deletions unweb/trusted/locales/rebuild_i18n
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh

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 "\n"
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 "\n"
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
6 changes: 4 additions & 2 deletions unweb/trusted/manage_membership.pt
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,11 @@
<input type="submit" name="save" value="Save changes" i18n:attributes="value" />
</div>

<div tal:condition="view/can_subscribe_others"><br />Use the above form to add allowed senders or to invite new mailing list members. Since you are a trusted list admin on openfsm.net you can instead <a class="listen-subscribe-members" href="subscribe_members">
<div tal:condition="view/can_subscribe_others"
i18n:translate="manage_membership_can_subscribe_others">
<br />Use the above form to add allowed senders or to invite new mailing list members. Since you are a trusted list admin on openfsm.net you can instead <a class="listen-subscribe-members" href="subscribe_members" i18n:translate="manage_membership_subscribe_members_directly" i18n:name="subscribe_members_directly">
subscribe new members directly</a>
without requiring their email confirmation. Please use with caution and only if certain that the user
without requiring their email confirmation. Please use with caution and only if certain that the user
will not object.</div>

<!-- ???
Expand Down
9 changes: 7 additions & 2 deletions unweb/trusted/manage_membership.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from opencore.i18n import _
from opencore.listen.browser.view import NuiManageMembersView
from Products.CMFCore.utils import getToolByName
from Products.listen.config import MEMBERSHIP_ALLOWED, MEMBERSHIP_DENIED
Expand Down Expand Up @@ -63,9 +64,13 @@ def subscribe_members(self):
plone_utils = getToolByName(context, 'plone_utils')

if errors:
plone_utils.addPortalMessage('Bad user or email address: %s' % ', '.join(errors))
plone_utils.addPortalMessage(_(u'manage_membership_bad_user_email_msg',
u'Bad user or email address: ${errors}',
mapping={'errors':', '.join(errors)}))

if added:
plone_utils.addPortalMessage('Added: %s' % ', '.join(added))
plone_utils.addPortalMessage(_(u'manage_membership_added_msg',
u'Added: ${added}',
mapping={'added':', '.join(added)}))

self.request.response.redirect(self.context.absolute_url()+'/manage_membership')
10 changes: 5 additions & 5 deletions unweb/trusted/subscribe_members.pt
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@
<div metal:use-macro="here/@@listen_macros/tabs"/>
<div id="oc-content-main">
<div class="oc-headingBlock">
<h2>Subscribe members</h2>
<h2 i18n:translate="">Subscribe members</h2>
</div>
<!-- subscribe members -->
<form name="subscribe-members" id="subscribe-members" method="post">

<div class="field">
<label for="emails">Emails:</label>
(enter e-mail addresses or usernames; use commas or newlines to separate;)
<label for="emails" i18n:translate="">Emails:</label>
<span i18n:translate="">(enter e-mail addresses or usernames; use commas or newlines to separate;)</span>
<div>
<textarea name="add_email"
rows="5"></textarea>
</div>
</div>

<input class="context" type="submit" name="subscribe" value="Subscribe"/>
<a href="manage_membership">Cancel</a>
<input class="context" type="submit" name="subscribe" value="Subscribe" i18n:attributes="value" />
<a href="manage_membership" i18n:translate="">Cancel</a>
</form>
</div>
</div>
Expand Down

0 comments on commit c9910fa

Please sign in to comment.