Skip to content

Commit

Permalink
Added more improvements about i18n support #2
Browse files Browse the repository at this point in the history
  • Loading branch information
macagua committed Jan 8, 2020
1 parent c5ec7bc commit 606cadc
Show file tree
Hide file tree
Showing 8 changed files with 173 additions and 8 deletions.
4 changes: 2 additions & 2 deletions opencore/feed/browser/feed_snippet.pt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<div tal:condition="not: feed/items">
<p i18n:translate="">
There are currently no
<span tal:replace="feed/itemstitle | default">items</span>
<span tal:replace="feed/itemstitle | default" i18n:name="feed_itemstitle">items</span>
</p>
</div>

Expand Down Expand Up @@ -52,7 +52,7 @@
</span>

<div tal:condition="entry/context | nothing">
from
<span i18n:translate="">from</span>
<a tal:omit-tag="not:entry/context/link"
tal:attributes="href entry/context/link"
tal:content="entry/context/title">
Expand Down
2 changes: 1 addition & 1 deletion opencore/feed/browser/headlink.pt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<link rel="alternate" type="application/rss+xml" title="RSS 2.0"
<link i18n:domain="opencore" rel="alternate" type="application/rss+xml" title="RSS 2.0" i18n:attributes="title"
tal:attributes="href string:${context/absolute_url}/rss" />
4 changes: 2 additions & 2 deletions opencore/feed/browser/portrait_feed_snippet.pt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<div tal:condition="not: context/items">
<p i18n:translate="">
There are currently no
<span tal:replace="context/itemstitle | default">items</span>
<span tal:replace="context/itemstitle | default" i18n:name="context_itemstitle">items</span>
</p>

</div>
Expand Down Expand Up @@ -51,7 +51,7 @@
tal:replace="python:view.pretty_date(date)"/>
</span>
<div tal:condition="entry/context | nothing">
from
<span i18n:translate="">from</span>
<a tal:omit-tag="not:entry/context/link"
tal:attributes="href entry/context/link"
tal:content="entry/context/title">
Expand Down
9 changes: 6 additions & 3 deletions opencore/feed/configure.zcml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<configure xmlns="http://namespaces.zope.org/zope"
xmlns:five="http://namespaces.zope.org/five"
>
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:five="http://namespaces.zope.org/five"
xmlns:i18n="http://namespaces.zope.org/i18n">

<i18n:registerTranslations directory="locales" />

<utility
provides="zope.component.interfaces.IFactory"
Expand Down
42 changes: 42 additions & 0 deletions opencore/feed/locales/en/LC_MESSAGES/opencore.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
msgid ""
msgstr ""
"Project-Id-Version: opencore\n"
"POT-Creation-Date: 2020-01-08 21:44+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"

#: ../browser/headlink.pt:1
msgid "RSS 2.0"
msgstr ""

#: ../browser/portrait_feed_snippet.pt:65
msgid "See all ${context_items_title}"
msgstr ""

#: ../browser/feed_snippet.pt:66
msgid "See all ${feed_items_title}"
msgstr ""

#: ../browser/portrait_feed_snippet.pt:13
msgid "There are currently no ${context_itemstitle}"
msgstr ""

#: ../browser/feed_snippet.pt:14
msgid "There are currently no ${feed_itemstitle}"
msgstr ""

#: ../browser/feed_snippet.pt:55
#: ../browser/portrait_feed_snippet.pt:54
msgid "from"
msgstr ""
46 changes: 46 additions & 0 deletions opencore/feed/locales/es/LC_MESSAGES/opencore.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Gettext Message File for Spanish translation of opencore domain using on opencore.feed package
# Translators:
# Leonardo J. Caballero G. <[email protected]>, 2020.
msgid ""
msgstr ""
"Project-Id-Version: opencore\n"
"POT-Creation-Date: 2020-01-08 21:44+0000\n"
"PO-Revision-Date: 2020-01-08 17:46-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"

#: ../browser/headlink.pt:1
msgid "RSS 2.0"
msgstr ""

#: ../browser/portrait_feed_snippet.pt:65
msgid "See all ${context_items_title}"
msgstr ""

#: ../browser/feed_snippet.pt:66
msgid "See all ${feed_items_title}"
msgstr ""

#: ../browser/portrait_feed_snippet.pt:13
msgid "There are currently no ${context_itemstitle}"
msgstr ""

#: ../browser/feed_snippet.pt:14
msgid "There are currently no ${feed_itemstitle}"
msgstr ""

#: ../browser/feed_snippet.pt:55
#: ../browser/portrait_feed_snippet.pt:54
msgid "from"
msgstr ""
43 changes: 43 additions & 0 deletions opencore/feed/locales/opencore.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# --- 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 21:44+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"

#: ../browser/headlink.pt:1
msgid "RSS 2.0"
msgstr ""

#: ../browser/portrait_feed_snippet.pt:65
msgid "See all ${context_items_title}"
msgstr ""

#: ../browser/feed_snippet.pt:66
msgid "See all ${feed_items_title}"
msgstr ""

#: ../browser/portrait_feed_snippet.pt:13
msgid "There are currently no ${context_itemstitle}"
msgstr ""

#: ../browser/feed_snippet.pt:14
msgid "There are currently no ${feed_itemstitle}"
msgstr ""

#: ../browser/feed_snippet.pt:55
#: ../browser/portrait_feed_snippet.pt:54
msgid "from"
msgstr ""
31 changes: 31 additions & 0 deletions opencore/feed/locales/rebuild_i18n
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/sh

domain='opencore'

# Synchronise the templates and scripts with the .pot file for opencore domain.
# i18ndude rebuild-pot --pot ./$domain.pot --create $domain --exclude ../browser/rss.pt ../
i18ndude rebuild-pot --pot ./$domain.pot \
--create $domain \
--exclude ../browser/rss.pt \
../browser/atom.pt ../browser/feed_snippet.pt ../browser/headlink.pt ../browser/portrait_feed_snippet.pt || exit 1

# 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 ""
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 ../browser/ -name "*pt" | xargs i18ndude find-untranslated > rebuild_i18n.log

0 comments on commit 606cadc

Please sign in to comment.