From cee7f1e0103e766087ce2bd2918106d58069ab4d Mon Sep 17 00:00:00 2001 From: systempuntoout Date: Thu, 17 Nov 2011 00:30:55 +0100 Subject: [PATCH] i18n --- app/config/settings.py | 14 +++--- app/config/translate.py | 97 +++++++++++++++++++++++++++++++++++++ app/config/urls.py | 19 +++++--- app/controllers/ajax.py | 1 - app/controllers/main.py | 23 ++++----- app/utility/utils.py | 14 +++++- app/views/__init__.py | 84 ++++++++++++++++---------------- app/views/featured.html | 12 ++--- app/views/feed.xml | 4 +- app/views/index.html | 18 +++---- app/views/layout.html | 32 ++++++------ app/views/oops.html | 2 +- app/views/post.html | 8 +-- app/views/sitemap_posts.xml | 2 +- app/views/tagcloud.html | 6 +-- application.py | 11 +++-- 16 files changed, 231 insertions(+), 116 deletions(-) create mode 100644 app/config/translate.py diff --git a/app/config/settings.py b/app/config/settings.py index 82de878..685af35 100644 --- a/app/config/settings.py +++ b/app/config/settings.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- #Meta -VERSION = '0.9.0.7' CMS_NAME = u"GAE Cupboard" AUTHOR_NAME = u"systempuntoout" SLOGAN = u"Ingredients for your Google App Engine recipes" @@ -33,6 +32,7 @@ ![test](/images/systempuntooutmail.jpg "mail") """ +FOOTER = " | ".join([u"© "+ AUTHOR_NAME, CMS_NAME,"Powered by Google App Engine"]) #Views @@ -59,17 +59,15 @@ ADSENSE_CHANNEL_ID = '2124691773' FEED_PROXY = 'http://feeds.feedburner.com/gaecupboard/fb' FEED_PROXY_USER_AGENT = 'FeedBurner' +GOOGLE_SITE_VERIFICATION_KEY = "m05zkgXk41nY4dXLheGpLdTiTnx-JduC2XOamAra_6Q" +YAHOO_SITE_VERIFICATION_KEY = "88698ce39daf8603" - -#Errors -RELAXING_MESSAGE_ERROR = "..cumulus clouds are white, puffy clouds that look like pieces of floating cotton.. " -GENERIC_ERROR = "Ooooops, it works on my machine. Please try again later." -NOT_FOUND_ERROR = "Not found!" -SERVER_ERROR = "Server problem" +#Stuff BOTS=['Googlebot','Slurp','Twiceler','msnbot','KaloogaBot','YodaoBot','Baiduspider','googlebot','Speedy Spider','DotBot'] MARKUPS = ['Markdown','Html'] DEFAULT_MARKUP = ['Markdown'] - +DEFAULT_LANGUAGE = 'en' +DATE_FORMAT = '%d %B, %Y' #Mapping Discovery AUTO_CONTENT_BY_LINK = { 'http://stackoverflow.com':{ diff --git a/app/config/translate.py b/app/config/translate.py new file mode 100644 index 0000000..9ad768d --- /dev/null +++ b/app/config/translate.py @@ -0,0 +1,97 @@ +# -*- coding: utf-8 -*- +en={} +it={} + +#Errors + +en['PAGE_NOT_FOUND_ERROR']=u"Not found!" +it['PAGE_NOT_FOUND_ERROR']=u"Non trovato" + +en['SERVER_ERROR']=u"Not found!" +it['SERVER_ERROR']=u"Non trovato" + +en['RELAXING_MESSAGE_ERROR'] = u"..cumulus clouds are white, puffy clouds that look like pieces of floating cotton.. " +it['RELAXING_MESSAGE_ERROR'] = u"Il Server ha avuto un problema nell'elaborazione della richiesta, prego riprovare più tardi" + +en['POST_NOT_FOUND_ERROR']=u"No posts found!" +it['POST_NOT_FOUND_ERROR']=u"Nessun articolo trovato" + +#Navigation + +en['ROUTE_ABOUT']=u"about" +it['ROUTE_ABOUT']=u"chisiamo" + +en['ROUTE_POST']=u"post" +it['ROUTE_POST']=u"articolo" + +en['ROUTE_FEATURED']=u"featured" +it['ROUTE_FEATURED']=u"dasegnalare" + +en['ROUTE_SEARCH']=u"search" +it['ROUTE_SEARCH']=u"cerca" + +en['ROUTE_TAGCLOUD']=u"tagcloud" +it['ROUTE_TAGCLOUD']=u"tags" + +en['TITLE_ERROR']=u"Error" +it['TITLE_ERROR']=u"Errore" + +en['TITLE_POST']=u"Posts" +it['TITLE_POST']=u"Articoli" + +en['TITLE_ABOUT']=u"About" +it['TITLE_ABOUT']=u"Chi Siamo" + +en['TITLE_FEATURED']=u"Featured" +it['TITLE_FEATURED']=u"Da segnalare" + +en['TITLE_SEARCH']=u"Search" +it['TITLE_SEARCH']=u"Cerca" + +en['TITLE_TAGCLOUD']=u"Tag cloud" +it['TITLE_TAGCLOUD']=u"Tags" + +en['TITLE_HOME']=u"Home" +it['TITLE_HOME']=u"Home" + +en['META_TAGCLOUD']=u"Weighted tags list that can be filtered" +it['META_TAGCLOUD']=u"Lista di tag che consentono di filtrare gli articoli in base all'argomento" + + +#Various +en['POSTS']=u"Posts" +it['POSTS']=u"Articoli" + +en['TAGS']=u"Tags" +it['TAGS']=u"Tags" + +en['BOOKS']=u"Books" +it['BOOKS']=u"Libri" + +en['CATEGORIES']=u"Categories" +it['CATEGORIES']=u"Categorie" + +en['DETAILS']=u"DETAILS" +it['DETAILS']=u"Dettagli" + +en['TAGS_SHOWN']=u"Tags shown" +it['TAGS_SHOWN']=u"Tags visualizzati" + +en['FILTER']=u"Filter" +it['FILTER']=u"Filtro" + +en['EVEN_MORE']=u"Even more" +it['EVEN_MORE']=u"Mostra tutti" + +en['PREV']=u"Prev" +it['PREV']=u"Indietro" + +en['NEXT']=u"Next" +it['NEXT']=u"Avanti" + +en['MORE']=u"More" +it['MORE']=u"Altri" + +en['SEARCH']=u"search" +it['SEARCH']=u"cerca" + diff --git a/app/config/urls.py b/app/config/urls.py index 79422e9..a67b07f 100644 --- a/app/config/urls.py +++ b/app/config/urls.py @@ -1,3 +1,6 @@ +import web +i18ns = web.i18ns + """ Routes to controllers """ @@ -5,13 +8,13 @@ urls = ( '/tag', 'app.controllers.main.Tags', '/tag/(.*)', 'app.controllers.main.Tags', - '/featured', 'app.controllers.main.Featured', - '/tagcloud','app.controllers.main.TagCloud', + '/%s' % i18ns['ROUTE_FEATURED'], 'app.controllers.main.Featured', + '/%s' % i18ns['ROUTE_TAGCLOUD'],'app.controllers.main.TagCloud', '/submit','app.controllers.main.Submit', - '/post', 'app.controllers.main.Post', - '/post/([\w_-]+)(?:/([\w-]+))?/?', 'app.controllers.main.Post', - '/about', 'app.controllers.main.About', - '/search', 'app.controllers.main.Search', + '/%s' % i18ns['ROUTE_POST'], 'app.controllers.main.Post', + '/%s/([\w_-]+)(?:/([\w-]+))?/?' % i18ns['ROUTE_POST'], 'app.controllers.main.Post', + '/%s' % i18ns['ROUTE_ABOUT'], 'app.controllers.main.About', + '/%s' % i18ns['ROUTE_SEARCH'], 'app.controllers.main.Search', '/img/([\w_-]+)(?:/.*)?', 'app.controllers.main.Image', '/ajax/tags','app.controllers.ajax.Tags', '/ajax/links','app.controllers.ajax.Links', @@ -37,6 +40,6 @@ sitemap_urls = ('/', '/tag', - '/post', + '/%s' % i18ns['ROUTE_POST'], '/featured', - '/about') + '/%s' % i18ns['ROUTE_ABOUT']) diff --git a/app/controllers/ajax.py b/app/controllers/ajax.py index 1866ca2..d4e5a9c 100644 --- a/app/controllers/ajax.py +++ b/app/controllers/ajax.py @@ -1,5 +1,4 @@ from google.appengine.api import memcache -from app.config.settings import GENERIC_ERROR, NOT_FOUND_ERROR import logging, web import app.db.models as models from google.appengine.ext import ereporter diff --git a/app/controllers/main.py b/app/controllers/main.py index cdfbfc3..eb02426 100644 --- a/app/controllers/main.py +++ b/app/controllers/main.py @@ -19,6 +19,7 @@ ereporter.register_logger() render = web.render +i18ns = web.i18ns def render_template(content, **kwargs): """ @@ -41,7 +42,7 @@ def render_error(error, **kwargs): """ Renders the error page """ - return render.layout(render.oops(error), title ='Error', navbar = False) + return render.layout(render.oops(error), title = i18ns['TITLE_ERROR'], navbar = False) class Index: @@ -59,7 +60,7 @@ def GET(self): selected_category = category, pagination = utils.Pagination(posts_count, page, POSTS_PER_PAGE), is_user_admin = users.is_current_user_admin()), - title = "%s" % (category if category else 'Home')) + title = "%s" % (category if category else i18ns['TITLE_HOME'])) class Post: @@ -72,7 +73,7 @@ def GET(self, post_id = None, slug = None): if post_id and not slug: post = models.Post.get(post_id) if post: - return web.seeother('/post/%s/%s' % (post_id, post.slug)) + return web.seeother('/%s/%s/%s' % (i18ns['ROUTE_POST'], post_id, post.slug)) else: raise web.notfound() #Get post @@ -84,7 +85,7 @@ def GET(self, post_id = None, slug = None): if post: #Return to canonical if the slug is truncated if slug and slug.strip() != post.slug: - return web.seeother('/post/%s/%s' % (post_id, post.slug)) + return web.seeother('/%s/%s/%s' % (i18ns['ROUTE_POST'],post_id, post.slug)) prev_post, next_post = models.Post.get_prev_next(post) else: @@ -96,7 +97,7 @@ def GET(self, post_id = None, slug = None): utils.ContentDiscoverer(post.link, post.category).get_content_block(), is_user_admin = users.is_current_user_admin()), title = post.title, - canonical = "post/%s" % (post.get_path()), + canonical = "%s/%s" % (i18ns['ROUTE_POST'],post.get_path()), meta_description = utils.get_metadescription(post)) except BadKeyError: raise web.notfound() @@ -143,7 +144,7 @@ def GET(self, tags = None): category, pagination = utils.Pagination(posts_count, page, POSTS_PER_PAGE), is_user_admin = users.is_current_user_admin()), - title = "%s %s" % (category if category else '',' '.join(tags) if tags else ('Posts' if not category else ''))) + title = "%s %s" % (category if category else '',' '.join(tags) if tags else (i18ns['TITLE_POST'] if not category else ''))) class TagCloud: @@ -158,8 +159,8 @@ def GET(self): else: tag_cloud = models.Tag.get_tags(MAIN_CLOUDSIZE) return render_template(render.tagcloud(tag_cloud, show_all), - title = 'Tag cloud', - meta_description = 'Weighted tags list that can be filtered') + title = i18ns['TITLE_TAGCLOUD'], + meta_description = i18ns['META_TAGCLOUD']) class Featured: """ @@ -169,21 +170,21 @@ def GET(self): featured_posts = models.Post.get_featured_posts() return render_template(render.featured(featured_posts, is_user_admin = users.is_current_user_admin()), - title = 'Featured') + title = i18ns['TITLE_FEATURED']) class About: """ About """ @cachepage() def GET(self): - return render_template(render.about(), title = 'About') + return render_template(render.about(), title = i18ns['TITLE_ABOUT']) class Search: """ Search """ def GET(self): - return render_template(render.search(), title = 'Search') + return render_template(render.search(), title = i18ns['TITLE_SEARCH']) class Feed: """ diff --git a/app/utility/utils.py b/app/utility/utils.py index 2cea86c..2c5b8bd 100644 --- a/app/utility/utils.py +++ b/app/utility/utils.py @@ -12,6 +12,7 @@ from app.config.settings import * from app.lib import pyso +import app.config.translate as translate @@ -173,4 +174,15 @@ def proxyfunc(self, *args, **kw): CACHE[url] = func(self, *args, **kw) return CACHE[url] return proxyfunc - return decorator \ No newline at end of file + return decorator + + +def get_i18ns(language): + """ + Return a dictionary with i18n strings of a given language (english by default) + """ + if hasattr(translate,language): + i18ns=getattr(translate,language) + else: + i18ns=translate.en + return i18ns \ No newline at end of file diff --git a/app/views/__init__.py b/app/views/__init__.py index 2f68e71..40f202d 100644 --- a/app/views/__init__.py +++ b/app/views/__init__.py @@ -76,16 +76,16 @@ def featured (posts, is_user_admin = False): extend_([' ', u' \n']) extend_([' ', u'
\n']) extend_([' ', u'
\n']) - extend_([' ', u'

', escape_(post.created.strftime("%d %B, %Y"), True), u'\n']) + extend_([' ', u'

', escape_(post.created.strftime(settings.DATE_FORMAT), True), u'\n']) if is_user_admin: extend_([' ', u'Edit\n']) if post.is_featured(): - extend_([' ', u'Featured\n']) - extend_([' ', u' | DETAILS\n']) + extend_([' ', u'', escape_(i18ns['TITLE_FEATURED'], True), u'\n']) + extend_([' ', u' | ', escape_(i18ns['DETAILS'], True), u'\n']) extend_([' ', u'

\n']) extend_([' ', u'

\n']) if post.link: - extend_([' ', u'', escape_((post.title), True), u'\n']) + extend_([' ', u'', escape_((post.title), True), u'\n']) else: extend_([' ', u'', escape_((post.title), True), u'\n']) extend_([' ', u'

\n']) @@ -127,7 +127,7 @@ def featured (posts, is_user_admin = False): extend_([' ', u' \n']) extend_([' ', u' \n']) extend_([' ', u' \n']) - extend_([' ', u' \n']) + extend_([' ', u' \n']) extend_([' ', u' \n']) extend_([' ', u'
Posts: ', escape_(commify(len(posts)), True), u'', escape_(i18ns['POSTS'], True), u': ', escape_(commify(len(posts)), True), u'
\n']) else: @@ -135,7 +135,7 @@ def featured (posts, is_user_admin = False): extend_([' ', u'\n']) extend_([' ', u' \n']) extend_([' ', u'

\n']) - extend_([' ', u' No posts found\n']) + extend_([' ', u' ', escape_(i18ns['POST_NOT_FOUND_ERROR'], True), u'\n']) extend_([' ', u'

\n']) extend_([' ', u' \n']) extend_([' ', u'\n']) @@ -166,8 +166,8 @@ def feed (posts, site_updated): for post in loop.setup(posts): extend_([u'\n']) extend_([u' ', escape_((post.title), True), u' - ', escape_((post.category), True), u'\n']) - extend_([u' \n']) - extend_([u' tag:', escape_((settings.HOST), True), u',', escape_((post.created.strftime("%Y-%m-%dT%H:%M:%SZ")), True), u':/post/', escape_((post.key()), True), u'\n']) + extend_([u' \n']) + extend_([u' tag:', escape_((settings.HOST), True), u',', escape_((post.created.strftime("%Y-%m-%dT%H:%M:%SZ")), True), u':/', escape_(i18ns['ROUTE_POST'], True), u'/', escape_((post.key()), True), u'\n']) extend_([u' ', escape_((post.created.strftime("%Y-%m-%dT%H:%M:%SZ")), True), u'\n']) extend_([u' ', escape_((post.last_modified.strftime("%Y-%m-%dT%H:%M:%SZ")), True), u'\n']) extend_([u' \n']) @@ -198,7 +198,7 @@ def render_catqs(selected_category, front_char): extend_([u'
\n']) extend_([u'
\n']) extend_([u'

\n']) - extend_([u' Tags:\n']) + extend_([u' ', escape_(i18ns['TAGS'], True), u':\n']) for tag in loop.setup(selected_tags): extend_([' ', u'', escape_(tag, True), u' x»\n']) extend_([u' \n']) @@ -228,16 +228,16 @@ def render_catqs(selected_category, front_char): extend_([' ', u' \n']) extend_([' ', u'

\n']) extend_([' ', u'
\n']) - extend_([' ', u'

', escape_(post.created.strftime("%d %B, %Y"), True), u'\n']) + extend_([' ', u'

', escape_(post.created.strftime(settings.DATE_FORMAT), True), u'\n']) if is_user_admin: extend_([' ', u'Edit\n']) if post.is_featured(): - extend_([' ', u'Featured\n']) - extend_([' ', u' | DETAILS\n']) + extend_([' ', u'', escape_(i18ns['TITLE_FEATURED'], True), u'\n']) + extend_([' ', u' | ', escape_(i18ns['DETAILS'], True), u'\n']) extend_([' ', u'

\n']) extend_([' ', u'

\n']) if post.link: - extend_([' ', u'', escape_((post.title), True), u'\n']) + extend_([' ', u'', escape_((post.title), True), u'\n']) else: extend_([' ', u'', escape_((post.title), True), u'\n']) extend_([' ', u'

\n']) @@ -286,14 +286,14 @@ def render_catqs(selected_category, front_char): extend_([' ', u' \n']) extend_([' ', u' \n']) if pagination.has_previous_entries(): - extend_([' ', u' « prev  \n']) + extend_([' ', u' « ', escape_(i18ns['PREV'], True), u'  \n']) extend_([' ', u' [ ', escape_(pagination.page, True), u' ]\n']) if pagination.has_more_entries(): - extend_([' ', u'   next »\n']) + extend_([' ', u'   ', escape_(i18ns['NEXT'], True), u' »\n']) extend_([' ', u' \n']) extend_([' ', u' \n']) extend_([' ', u' \n']) - extend_([' ', u' Posts: ', escape_(commify(pagination.total), True), u'\n']) + extend_([' ', u' ', escape_(i18ns['POSTS'], True), u': ', escape_(commify(pagination.total), True), u'\n']) extend_([' ', u' \n']) extend_([' ', u' \n']) else: @@ -301,7 +301,7 @@ def render_catqs(selected_category, front_char): extend_([' ', u'\n']) extend_([' ', u' \n']) extend_([' ', u'

\n']) - extend_([' ', u' No posts found\n']) + extend_([' ', u' ', escape_(i18ns['POST_NOT_FOUND_ERROR'], True), u'\n']) extend_([' ', u'

\n']) extend_([' ', u' \n']) extend_([' ', u'\n']) @@ -324,8 +324,8 @@ def layout (content, title = None , tag_cloud = [], categories = [], navbar = Tr extend_([u'\n']) extend_([u'\n']) extend_([u'\n']) - extend_([u' \n']) - extend_([u' \n']) + extend_([u' \n']) + extend_([u' \n']) if settings.FEED_PROXY: extend_([' ', u'\n']) else: @@ -333,9 +333,9 @@ def layout (content, title = None , tag_cloud = [], categories = [], navbar = Tr extend_([u' \n']) extend_([u' \n']) extend_([u' \n']) - if title == 'Tag cloud': + if title == i18ns['TITLE_TAGCLOUD']: extend_([' ', u'\n']) - if title == 'Home': + if title == i18ns['TITLE_HOME']: extend_([' ', u'', escape_(settings.CMS_NAME, True), u' \n']) else: extend_([' ', u' ', escape_((title), True), u' - ', escape_(settings.CMS_NAME, True), u' \n']) @@ -382,11 +382,11 @@ def layout (content, title = None , tag_cloud = [], categories = [], navbar = Tr extend_([u'

', escape_(settings.CMS_NAME, True), u' Logo

\n']) extend_([u'

', escape_((settings.SLOGAN), True), u'

\n']) extend_([u' \n']) @@ -395,7 +395,7 @@ def layout (content, title = None , tag_cloud = [], categories = [], navbar = Tr extend_([u' \n']) extend_([u' \n']) extend_([u' \n']) - extend_([u' \n']) + extend_([u' \n']) extend_([u'

\n']) extend_([u' \n']) extend_([u' \n']) @@ -428,7 +428,7 @@ def layout (content, title = None , tag_cloud = [], categories = [], navbar = Tr extend_([u' \n']) extend_([u' \n']) extend_([u'\n']) - extend_([u'

Posts: ', escape_(commify(posts_total_count), True), u'

\n']) + extend_([u'

', escape_(i18ns['POSTS'], True), u': ', escape_(commify(posts_total_count), True), u'

\n']) extend_([u' \n']) extend_([u' \n']) extend_([u'
\n']) extend_([u'
\n']) - extend_([u'

', escape_(post.created.strftime("%d %B, %Y"), True), u' | ', escape_(settings.CMS_NAME, True), u'\n']) + extend_([u'

', escape_(post.created.strftime(settings.DATE_FORMAT), True), u' | ', escape_(settings.CMS_NAME, True), u'\n']) if post.is_featured(): - extend_([' ', u'Featured\n']) + extend_([' ', u'', escape_(i18ns['TITLE_FEATURED'], True), u'\n']) extend_([u' Permalink\n']) if is_user_admin: extend_([' ', u'Edit\n']) @@ -738,7 +738,7 @@ def sitemap_posts (posts): extend_([u'http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">\n']) for post in loop.setup(posts): extend_([' ', u'\n']) - extend_([' ', u' http://', escape_((settings.HOST), True), u'/post/', escape_((post.get_path()), True), u'\n']) + extend_([' ', u' http://', escape_((settings.HOST), True), u'/', escape_(i18ns['ROUTE_POST'], True), u'/', escape_((post.get_path()), True), u'\n']) extend_([' ', u'\n']) extend_([u'\n']) @@ -796,13 +796,13 @@ def tagcloud (tag_cloud, show_all = False): self = TemplateResult(); extend_ = self.extend max_occurrencies = tag_cloud[0].counter if len(tag_cloud)>0 else 1 extend_([u'\n']) - extend_([u'

Tags shown: ', escape_(commify(len(tag_cloud)), True), u'

\n']) - extend_([u'

Filter:

\n']) + extend_([u'

', escape_(i18ns['TAGS_SHOWN'], True), u': ', escape_(commify(len(tag_cloud)), True), u'

\n']) + extend_([u'

', escape_(i18ns['FILTER'], True), u':

\n']) extend_([u'
\n']) for tag in loop.setup(tag_cloud): extend_([' ', u' ', escape_((tag.name), True), u'(', escape_(commify(tag.counter), True), u') \n']) if len(tag_cloud)>=settings.MAIN_CLOUDSIZE and not show_all: - extend_([' ', u'
even more \xbb\n']) + extend_([' ', u'
', escape_(i18ns['EVEN_MORE'], True), u' \xbb\n']) extend_([u'
\n']) return self diff --git a/app/views/featured.html b/app/views/featured.html index d93de06..aacdfc9 100644 --- a/app/views/featured.html +++ b/app/views/featured.html @@ -6,16 +6,16 @@
-

$post.created.strftime("%d %B, %Y") +

$post.created.strftime(settings.DATE_FORMAT) $if is_user_admin: Edit $if post.is_featured(): - Featured - | DETAILS + $i18ns['TITLE_FEATURED'] + | $i18ns['DETAILS']

$if post.link: - $(post.title) + $(post.title) $else: $(post.title)

@@ -57,7 +57,7 @@ - +
Posts: $commify(len(posts))$i18ns['POSTS']: $commify(len(posts))
$else: @@ -65,7 +65,7 @@

- No posts found + $i18ns['POST_NOT_FOUND_ERROR']

diff --git a/app/views/feed.xml b/app/views/feed.xml index e9506bc..784e5e9 100644 --- a/app/views/feed.xml +++ b/app/views/feed.xml @@ -11,8 +11,8 @@ $def with (posts, site_updated) $for post in posts: $(post.title) - $(post.category) - - tag:$(settings.HOST),$(post.created.strftime("%Y-%m-%dT%H:%M:%SZ")):/post/$(post.key()) + + tag:$(settings.HOST),$(post.created.strftime("%Y-%m-%dT%H:%M:%SZ")):/$i18ns['ROUTE_POST']/$(post.key()) $(post.created.strftime("%Y-%m-%dT%H:%M:%SZ")) $(post.last_modified.strftime("%Y-%m-%dT%H:%M:%SZ")) diff --git a/app/views/index.html b/app/views/index.html index 920808b..97d230f 100755 --- a/app/views/index.html +++ b/app/views/index.html @@ -5,7 +5,7 @@

- Tags: + $i18ns['TAGS']: $for tag in selected_tags: $tag x» @@ -35,16 +35,16 @@

-

$post.created.strftime("%d %B, %Y") +

$post.created.strftime(settings.DATE_FORMAT) $if is_user_admin: Edit $if post.is_featured(): - Featured - | DETAILS + $i18ns['TITLE_FEATURED'] + | $i18ns['DETAILS']

$if post.link: - $(post.title) + $(post.title) $else: $(post.title)

@@ -93,14 +93,14 @@ $if pagination.has_previous_entries(): - « prev   + « $i18ns['PREV']   [ $pagination.page ] $if pagination.has_more_entries(): -   next » +   $i18ns['NEXT'] » - Posts: $commify(pagination.total) + $i18ns['POSTS']: $commify(pagination.total) $else: @@ -108,7 +108,7 @@

- No posts found + $i18ns['POST_NOT_FOUND_ERROR']

diff --git a/app/views/layout.html b/app/views/layout.html index 914492e..7b696e4 100644 --- a/app/views/layout.html +++ b/app/views/layout.html @@ -3,8 +3,8 @@ - - + + $if settings.FEED_PROXY: $else: @@ -12,9 +12,9 @@ - $if title == 'Tag cloud': + $if title == i18ns['TITLE_TAGCLOUD']: - $if title == 'Home': + $if title == i18ns['TITLE_HOME']: $settings.CMS_NAME $else: $(title) - $settings.CMS_NAME @@ -61,11 +61,11 @@

$settings.CMS_NAME Logo

$(settings.SLOGAN)

@@ -74,7 +74,7 @@

$(settings.SLOGAN)

- +

@@ -107,7 +107,7 @@

$(settings.SLOGAN)

-

Posts: $commify(posts_total_count)

+

$i18ns['POSTS']: $commify(posts_total_count)

-

$post.created.strftime("%d %B, %Y") | $settings.CMS_NAME +

$post.created.strftime(settings.DATE_FORMAT) | $settings.CMS_NAME $if post.is_featured(): - Featured + $i18ns['TITLE_FEATURED'] Permalink $if is_user_admin: Edit diff --git a/app/views/sitemap_posts.xml b/app/views/sitemap_posts.xml index 96b0515..14df960 100644 --- a/app/views/sitemap_posts.xml +++ b/app/views/sitemap_posts.xml @@ -7,6 +7,6 @@ $def with (posts) http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"> $for post in posts: - http://$(settings.HOST)/post/$(post.get_path()) + http://$(settings.HOST)/$i18ns['ROUTE_POST']/$(post.get_path()) diff --git a/app/views/tagcloud.html b/app/views/tagcloud.html index 3280c15..750bd2b 100644 --- a/app/views/tagcloud.html +++ b/app/views/tagcloud.html @@ -1,11 +1,11 @@ $def with (tag_cloud, show_all = False) $ max_occurrencies = tag_cloud[0].counter if len(tag_cloud)>0 else 1 -

Tags shown: $commify(len(tag_cloud))

-

Filter:

+

$i18ns['TAGS_SHOWN']: $commify(len(tag_cloud))

+

$i18ns['FILTER']:

$for tag in tag_cloud: $(tag.name)($commify(tag.counter))  $if len(tag_cloud)>=settings.MAIN_CLOUDSIZE and not show_all: -
even more » +
$i18ns['EVEN_MORE'] »
\ No newline at end of file diff --git a/application.py b/application.py index c8bf213..ae34f26 100755 --- a/application.py +++ b/application.py @@ -10,10 +10,11 @@ import web import app.utility.utils as utils -from app.config.urls import urls import app.config.settings as settings from app.config.settings import * +web.i18ns = utils.get_i18ns(DEFAULT_LANGUAGE) + global_template = { 'safemarkdown':web.safemarkdown, 'commify': web.utils.commify, @@ -21,16 +22,20 @@ 'htmlquote':web.net.htmlquote, 'settings': settings, 'utils': utils, + 'i18ns': web.i18ns, 'development' : os.environ['SERVER_SOFTWARE'].startswith('Dev') } web.render = render = web.template.render('app/views/', globals = global_template, cache = True) + + def notfound(): - return web.notfound(render.layout(render.oops(settings.NOT_FOUND_ERROR), title ='Error', navbar = False, is_user_admin = users.is_current_user_admin())) + return web.notfound(render.layout(render.oops(web.i18ns['PAGE_NOT_FOUND_ERROR']), title ='Error', navbar = False, is_user_admin = users.is_current_user_admin())) def internalerror(): - return web.internalerror(render.layout(render.oops(settings.SERVER_ERROR), title ='Error', navbar = False, is_user_admin = users.is_current_user_admin())) + return web.internalerror(render.layout(render.oops(web.i18ns['SERVER_ERROR']), title ='Error', navbar = False, is_user_admin = users.is_current_user_admin())) +from app.config.urls import urls app = web.application(urls, globals()) app.notfound = notfound app.internalerror = internalerror