On Sun, 2007-07-29 at 14:10 +0200, Daniel de Kok wrote:
> On Thu, 2007-07-26 at 19:36 +0200, Ralph Angenendt wrote:
> > I'd say "Link to es/ from the FrontPage". Even though not all articles
> > are there.
> >
> > Let us wait for Daniel to come back, he has a plugin which redirects to
> > the English page if a spanish page isn't there. And that has to be
> > installed.
>
> I'll see if I can get a recent dump from Lance, and will polish the
> plugin for production use.
I have attached a slightly altered version that handles some bogus
requests, and allows us to add warnings in native languages. This is
what it will currently show if a translation does not exist:
http://people.centos.org/~daniel/code/moin/missing-translation/missing-translation.png
Or a localized variant if it is available:
http://people.centos.org/~daniel/code/moin/missing-translation/missing-translation-native.png
Current version is attached.
-- Daniel
# -*- coding: utf-8 -*-
"""
MoinMoin - show plugin with fall-back for non-native languages
@copyright: 2007 by Daniel de Kok
@license: GNU GPL
"""
from MoinMoin.Page import Page
nonEnglishLangs = ['es', 'fr', 'nl']
unknownPageMessages = {
'nl': 'Er bestaat geen vertaling van deze pagina, daarom wordt de ' + \
'Engelstalige pagina getoond!',
}
def execute(pagename, request):
page = Page(request, pagename)
# If the requested page exists, all is fine, and we can return
if page.exists():
page.send_page(request)
return
# Does the page name have the form <lang>/Foo/Bar?
pageParts = pagename.split('/')
if len(pageParts) > 0 and pageParts[0] in nonEnglishLangs:
# Seems that a non-English page was requested that does
# not exist, look if the English page exists. If so, show it.
lang = pageParts[0]
# pageParts[0] = 'en'
del pageParts[0]
# Bogus page request?
if pageParts[0] in nonEnglishLangs:
page.send_page(request)
return
tryPage = Page(request, '/'.join(pageParts))
if tryPage.exists():
if unknownPageMessages.has_key(lang):
msg = unknownPageMessages[lang]
else:
msg = 'Currently, there is no translation available for this page, ' + \
'the English page is shown instead!'
tryPage.send_page(request, msg = msg)
return
# The page does not exist, and an English page is also absent.
page.send_page(request)
_______________________________________________
CentOS-docs mailing list
[email protected]
http://lists.centos.org/mailman/listinfo/centos-docs