start internationalisation
* add babel stuff to setup.py * translate existing templates (addresses #11) * translate existing controllers git-svn-id: file:///var/www/wwwusers/usr01/svn/pyalchemybiz/trunk@9 389c73d4-bf09-4d3d-a15e-f94a37d0667a
This commit is contained in:
parent
b53e8c48df
commit
1bbcc8e559
9 changed files with 112 additions and 11 deletions
|
@ -8,6 +8,7 @@ log = logging.getLogger(__name__)
|
||||||
class IndexController(BaseController):
|
class IndexController(BaseController):
|
||||||
|
|
||||||
def index(self):
|
def index(self):
|
||||||
|
c.menuitems = [(_("Customer management"), "customer", "index")]
|
||||||
# Return a rendered template
|
# Return a rendered template
|
||||||
# return render('/some/template.mako')
|
# return render('/some/template.mako')
|
||||||
# or, Return a response
|
# or, Return a response
|
||||||
|
|
BIN
pyalchemybiz/i18n/de/LC_MESSAGES/pyalchemybiz.mo
Normal file
BIN
pyalchemybiz/i18n/de/LC_MESSAGES/pyalchemybiz.mo
Normal file
Binary file not shown.
45
pyalchemybiz/i18n/de/LC_MESSAGES/pyalchemybiz.po
Normal file
45
pyalchemybiz/i18n/de/LC_MESSAGES/pyalchemybiz.po
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
# German translations for pyalchemybiz.
|
||||||
|
# Copyright (C) 2008 ORGANIZATION
|
||||||
|
# This file is distributed under the same license as the pyalchemybiz
|
||||||
|
# project.
|
||||||
|
# Jan Dittberner <jan@dittberner.info>, 2008.
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: pyalchemybiz 0.1\n"
|
||||||
|
"Report-Msgid-Bugs-To: jan@dittberner.info\n"
|
||||||
|
"POT-Creation-Date: 2008-10-06 00:50+0200\n"
|
||||||
|
"PO-Revision-Date: 2008-10-06 01:10+0200\n"
|
||||||
|
"Last-Translator: Jan Dittberner <jan@dittberner.info>\n"
|
||||||
|
"Language-Team: de <de@li.org>\n"
|
||||||
|
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=utf-8\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
"Generated-By: Babel 0.9.1\n"
|
||||||
|
|
||||||
|
#: pyalchemybiz/controllers/index.py:11
|
||||||
|
msgid "Customer management"
|
||||||
|
msgstr "Kundenverwaltung"
|
||||||
|
|
||||||
|
#: pyalchemybiz/templates/base.mako:5
|
||||||
|
msgid "PyAlchemyBiz"
|
||||||
|
msgstr "PyAlchemyBiz"
|
||||||
|
|
||||||
|
#: pyalchemybiz/templates/base.mako:14
|
||||||
|
#, python-format
|
||||||
|
msgid "Return to the %s."
|
||||||
|
msgstr "Zurück zur %s."
|
||||||
|
|
||||||
|
#: pyalchemybiz/templates/base.mako:15
|
||||||
|
msgid "FrontPage"
|
||||||
|
msgstr "Startseite"
|
||||||
|
|
||||||
|
#: pyalchemybiz/templates/customer/index.mako:3
|
||||||
|
msgid "Hello"
|
||||||
|
msgstr "Hallo"
|
||||||
|
|
||||||
|
#: pyalchemybiz/templates/customer/index.mako:7
|
||||||
|
msgid "edit"
|
||||||
|
msgstr "bearbeiten"
|
||||||
|
|
44
pyalchemybiz/i18n/pyalchemybiz.pot
Normal file
44
pyalchemybiz/i18n/pyalchemybiz.pot
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
# Translations template for pyalchemybiz.
|
||||||
|
# Copyright (C) 2008 ORGANIZATION
|
||||||
|
# This file is distributed under the same license as the pyalchemybiz project.
|
||||||
|
# FIRST AUTHOR <EMAIL@ADDRESS>, 2008.
|
||||||
|
#
|
||||||
|
#, fuzzy
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: pyalchemybiz 0.1\n"
|
||||||
|
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
|
||||||
|
"POT-Creation-Date: 2008-10-06 01:10+0200\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"
|
||||||
|
"Generated-By: Babel 0.9.1\n"
|
||||||
|
|
||||||
|
#: pyalchemybiz/controllers/index.py:11
|
||||||
|
msgid "Customer management"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: pyalchemybiz/templates/base.mako:5
|
||||||
|
msgid "PyAlchemyBiz"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: pyalchemybiz/templates/base.mako:14
|
||||||
|
#, python-format
|
||||||
|
msgid "Return to the %s."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: pyalchemybiz/templates/base.mako:15
|
||||||
|
msgid "FrontPage"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: pyalchemybiz/templates/customer/index.mako:3
|
||||||
|
msgid "Hello"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: pyalchemybiz/templates/customer/index.mako:7
|
||||||
|
msgid "edit"
|
||||||
|
msgstr ""
|
||||||
|
|
|
@ -7,7 +7,7 @@ from pylons import c, cache, config, g, request, response, session
|
||||||
from pylons.controllers import WSGIController
|
from pylons.controllers import WSGIController
|
||||||
from pylons.controllers.util import abort, etag_cache, redirect_to
|
from pylons.controllers.util import abort, etag_cache, redirect_to
|
||||||
from pylons.decorators import jsonify, validate
|
from pylons.decorators import jsonify, validate
|
||||||
from pylons.i18n import _, ungettext, N_
|
from pylons.i18n import _, ungettext, N_, add_fallback, set_lang
|
||||||
from pylons.templating import render
|
from pylons.templating import render
|
||||||
|
|
||||||
import pyalchemybiz.lib.helpers as h
|
import pyalchemybiz.lib.helpers as h
|
||||||
|
@ -24,6 +24,13 @@ class BaseController(WSGIController):
|
||||||
# WSGIController.__call__ dispatches to the Controller method
|
# WSGIController.__call__ dispatches to the Controller method
|
||||||
# the request is routed to. This routing information is
|
# the request is routed to. This routing information is
|
||||||
# available in environ['pylons.routes_dict']
|
# available in environ['pylons.routes_dict']
|
||||||
|
# set language environment
|
||||||
|
for lang in request.languages:
|
||||||
|
try:
|
||||||
|
add_fallback(lang)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
# connect to database
|
||||||
conn = meta.engine.connect()
|
conn = meta.engine.connect()
|
||||||
meta.Session.configure(bind=conn)
|
meta.Session.configure(bind=conn)
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>PyAlchemyBiz</title>
|
<title>${_('PyAlchemyBiz')}</title>
|
||||||
${h.stylesheet_link_tag('/pyalchemybiz.css')}
|
${h.stylesheet_link_tag('/pyalchemybiz.css')}
|
||||||
${h.javascript_include_tag(
|
${h.javascript_include_tag(
|
||||||
'/javascripts/pyalchemybiz.js', builtins=True)}
|
'/javascripts/pyalchemybiz.js', builtins=True)}
|
||||||
|
@ -11,8 +11,8 @@
|
||||||
<div class="content">
|
<div class="content">
|
||||||
${next.body()}\
|
${next.body()}\
|
||||||
<p class="footer">
|
<p class="footer">
|
||||||
Return to the
|
${_("Return to the %s.") % \
|
||||||
${h.link_to('FrontPage',
|
h.link_to(_('FrontPage'),
|
||||||
h.url_for(controller="index", action="index"))}
|
h.url_for(controller="index", action="index"))}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
<%inherit file="/base.mako" />
|
<%inherit file="/base.mako" />
|
||||||
|
|
||||||
<h1>Hallo</h1>
|
<h1>${_('Hello')}</h1>
|
||||||
|
|
||||||
<ul id="customers">
|
<ul id="customers">
|
||||||
% for customer in c.customers:
|
% for customer in c.customers:
|
||||||
<li>${h.escape_once(customer)} [${h.link_to('edit', h.url_for(id=customer.id, action="edit"))}]</li>
|
<li>${customer | h} [${h.link_to(_('edit'), h.url_for(id=customer.id, action="edit"))}]</li>
|
||||||
% endfor
|
% endfor
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
<%inherit file="base.mako" />
|
<%inherit file="base.mako" />
|
||||||
|
|
||||||
${h.link_to('customers', h.url_for(controller="customer", action="index"))}
|
<ul id="menu">
|
||||||
|
% for item in c.menuitems:
|
||||||
|
<li>${h.link_to(item[0], h.url_for(controller=item[1], action=item[2]))}</li>
|
||||||
|
% endfor
|
||||||
|
</ul>
|
8
setup.py
8
setup.py
|
@ -18,10 +18,10 @@ setup(
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
test_suite='nose.collector',
|
test_suite='nose.collector',
|
||||||
package_data={'pyalchemybiz': ['i18n/*/LC_MESSAGES/*.mo']},
|
package_data={'pyalchemybiz': ['i18n/*/LC_MESSAGES/*.mo']},
|
||||||
#message_extractors = {'pyalchemybiz': [
|
message_extractors = {'pyalchemybiz': [
|
||||||
# ('**.py', 'python', None),
|
('**.py', 'python', None),
|
||||||
# ('templates/**.mako', 'mako', None),
|
('templates/**.mako', 'mako', None),
|
||||||
# ('public/**', 'ignore', None)]},
|
('public/**', 'ignore', None)]},
|
||||||
entry_points="""
|
entry_points="""
|
||||||
[paste.app_factory]
|
[paste.app_factory]
|
||||||
main = pyalchemybiz.config.middleware:make_app
|
main = pyalchemybiz.config.middleware:make_app
|
||||||
|
|
Loading…
Reference in a new issue