diff --git a/pyalchemybiz/controllers/index.py b/pyalchemybiz/controllers/index.py index e959244..8549b3c 100644 --- a/pyalchemybiz/controllers/index.py +++ b/pyalchemybiz/controllers/index.py @@ -8,6 +8,7 @@ log = logging.getLogger(__name__) class IndexController(BaseController): def index(self): + c.menuitems = [(_("Customer management"), "customer", "index")] # Return a rendered template # return render('/some/template.mako') # or, Return a response diff --git a/pyalchemybiz/i18n/de/LC_MESSAGES/pyalchemybiz.mo b/pyalchemybiz/i18n/de/LC_MESSAGES/pyalchemybiz.mo new file mode 100644 index 0000000..28b70e6 Binary files /dev/null and b/pyalchemybiz/i18n/de/LC_MESSAGES/pyalchemybiz.mo differ diff --git a/pyalchemybiz/i18n/de/LC_MESSAGES/pyalchemybiz.po b/pyalchemybiz/i18n/de/LC_MESSAGES/pyalchemybiz.po new file mode 100644 index 0000000..9d354de --- /dev/null +++ b/pyalchemybiz/i18n/de/LC_MESSAGES/pyalchemybiz.po @@ -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 , 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 \n" +"Language-Team: de \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" + diff --git a/pyalchemybiz/i18n/pyalchemybiz.pot b/pyalchemybiz/i18n/pyalchemybiz.pot new file mode 100644 index 0000000..afe1aef --- /dev/null +++ b/pyalchemybiz/i18n/pyalchemybiz.pot @@ -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 , 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 \n" +"Language-Team: LANGUAGE \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 "" + diff --git a/pyalchemybiz/lib/base.py b/pyalchemybiz/lib/base.py index 7933628..4bbaf27 100644 --- a/pyalchemybiz/lib/base.py +++ b/pyalchemybiz/lib/base.py @@ -7,7 +7,7 @@ from pylons import c, cache, config, g, request, response, session from pylons.controllers import WSGIController from pylons.controllers.util import abort, etag_cache, redirect_to 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 import pyalchemybiz.lib.helpers as h @@ -24,6 +24,13 @@ class BaseController(WSGIController): # WSGIController.__call__ dispatches to the Controller method # the request is routed to. This routing information is # 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() meta.Session.configure(bind=conn) try: diff --git a/pyalchemybiz/templates/base.mako b/pyalchemybiz/templates/base.mako index f9b2739..b3f1cf4 100644 --- a/pyalchemybiz/templates/base.mako +++ b/pyalchemybiz/templates/base.mako @@ -2,7 +2,7 @@ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> - PyAlchemyBiz + ${_('PyAlchemyBiz')} ${h.stylesheet_link_tag('/pyalchemybiz.css')} ${h.javascript_include_tag( '/javascripts/pyalchemybiz.js', builtins=True)} @@ -11,8 +11,8 @@
${next.body()}\
diff --git a/pyalchemybiz/templates/customer/index.mako b/pyalchemybiz/templates/customer/index.mako index 20989c6..58055e6 100644 --- a/pyalchemybiz/templates/customer/index.mako +++ b/pyalchemybiz/templates/customer/index.mako @@ -1,9 +1,9 @@ <%inherit file="/base.mako" /> -

Hallo

+

${_('Hello')}

    % for customer in c.customers: -
  • ${h.escape_once(customer)} [${h.link_to('edit', h.url_for(id=customer.id, action="edit"))}]
  • +
  • ${customer | h} [${h.link_to(_('edit'), h.url_for(id=customer.id, action="edit"))}]
  • % endfor
diff --git a/pyalchemybiz/templates/index.mako b/pyalchemybiz/templates/index.mako index 24b60ec..37fd53a 100644 --- a/pyalchemybiz/templates/index.mako +++ b/pyalchemybiz/templates/index.mako @@ -1,3 +1,7 @@ <%inherit file="base.mako" /> -${h.link_to('customers', h.url_for(controller="customer", action="index"))} \ No newline at end of file + \ No newline at end of file diff --git a/setup.py b/setup.py index ce20d15..6e3fa76 100755 --- a/setup.py +++ b/setup.py @@ -18,10 +18,10 @@ setup( include_package_data=True, test_suite='nose.collector', package_data={'pyalchemybiz': ['i18n/*/LC_MESSAGES/*.mo']}, - #message_extractors = {'pyalchemybiz': [ - # ('**.py', 'python', None), - # ('templates/**.mako', 'mako', None), - # ('public/**', 'ignore', None)]}, + message_extractors = {'pyalchemybiz': [ + ('**.py', 'python', None), + ('templates/**.mako', 'mako', None), + ('public/**', 'ignore', None)]}, entry_points=""" [paste.app_factory] main = pyalchemybiz.config.middleware:make_app