Skip to content

Commit

Permalink
translate the get original file link
Browse files Browse the repository at this point in the history
  • Loading branch information
maartenkling committed Jul 3, 2012
1 parent cbe8c45 commit ca38340
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 5 deletions.
4 changes: 4 additions & 0 deletions collective/geo/fastkml/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
from zope.i18nmessageid import MessageFactory

MessageFactory = MessageFactory('collective.geo.fastkml')


def initialize(context):
"""Initializer called when used as a Zope 2 product."""
13 changes: 9 additions & 4 deletions collective/geo/fastkml/browser/kmldocument.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,19 @@

from shapely.geometry import asShape

from collective.geo.fastkml import MessageFactory as _
from zope.i18n import translate


class FastKMLBaseDocument(KMLBaseDocument):

anchorsnippet = '''<p class="placemark-url">
<a href="%s">See the original resource</a>
</p>'''
def anchorsnippet(self, link):
snippettext = self.context.translate(_(u'See the original resource'))
return '''<p class="placemark-url">
<a href="%s">%s</a></p>''' % (link, snippettext)

def get_kml(self):

k = kml.KML()
## make sure description field is encoded properly
desc = unicode(self.description, \
Expand All @@ -39,7 +44,7 @@ def get_kml(self):
description = unicode(feature.description, \
'utf-8').encode('ascii', 'xmlcharrefreplace')
if feature.item_url:
description += self.anchorsnippet % feature.item_url
description += self.anchorsnippet(feature.item_url)
pm = kml.Placemark(name=feature.name, description=description)
shape = {'type': feature.geom.type,
'coordinates': feature.geom.coordinates}
Expand Down
4 changes: 3 additions & 1 deletion collective/geo/fastkml/configure.zcml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?xml version="1.0"?>
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:five="http://namespaces.zope.org/five"
xmlns:i18n="http://namespaces.zope.org/i18n"
i18n_domain="collective.geo.fastkml">

<five:registerPackage package="." initialize=".initialize" />

<i18n:registerTranslations directory="locales" />

<include file="profiles.zcml" />
<include package=".browser" />

Expand Down
23 changes: 23 additions & 0 deletions collective/geo/fastkml/locales/collective.geo.fastkml.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# --- 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: 2012-07-03 13:26+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: collective.geo.fastkml\n"

#: ../browser/kmldocument.py:20
msgid "See the original resource"
msgstr ""

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
msgid ""
msgstr ""
"Project-Id-Version: 0.1\n"
"POT-Creation-Date: 2012-07-03 13:26+0000\n"
"PO-Revision-Date: 2012-07-03 12:35+0000\n"
"Last-Translator: Maarten Kling <maarten@fourdigits.nl>\n"
"Language-Team: Maarten Kling <maarten@fourdigits.nl>\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: nl\n"
"Language-Name: Dutch\n"
"Preferred-Encodings: utf-8 latin1\n"
"Domain: collective.geo.fastkml\n"
"X-is-fallback-for: nl-be\n"

#: ../browser/kmldocument.py:20
msgid "See the original resource"
msgstr "Zie de originele bron"
23 changes: 23 additions & 0 deletions collective/geo/fastkml/locales/rebuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

PRODUCT=collective.geo.fastkml

i18ndude rebuild-pot --pot ../locales/${PRODUCT}.pot --create $PRODUCT ../
i18ndude sync --pot ../locales/${PRODUCT}.pot ../locales/*/LC_MESSAGES/${PRODUCT}.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
# Ok, now poedit is your friend!

0 comments on commit ca38340

Please sign in to comment.