changeset 363:2bf44dde5191

shows a table of System Pages and their translations to the users language
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Tue, 14 Apr 2009 22:54:32 +0200
parents ff2e57ddeb68
children 5fbb949f75d2
files data/plugin/action/SystemPages.py
diffstat 1 files changed, 48 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data/plugin/action/SystemPages.py	Tue Apr 14 22:54:32 2009 +0200
@@ -0,0 +1,48 @@
+# -*- coding: iso-8859-1 -*-
+"""
+    MoinMoin - SystemPages
+
+    shows a table of System Pages and their translations to the users language
+    if the user lang is anything else than en
+
+    @copyright: 2009 MoinMoin:ReimarBauer
+    @license: GNU GPL, see COPYING for details.
+"""
+
+from MoinMoin.i18n import strings
+from MoinMoin import i18n
+from MoinMoin.Page import Page
+from MoinMoin.util.dataset import TupleDataset, Column
+from MoinMoin.widget.browser import DataBrowserWidget
+
+
+def execute(pagename, request):
+    _ = request.getText
+    SystemPages = strings.all_pages
+
+    users_lang = i18n.requestLanguage(request)
+    if users_lang == "en":
+        msg = _("Please select an other language than english in your settings for this action")
+        request.theme.add_msg(msg, "err")
+        Page(request, pagename).send_page()
+        return
+
+    data = TupleDataset()
+    data.columns = [
+           Column('en', label=_('Developer language')),
+           Column(users_lang, label=_('Preferred language')),
+        ]
+
+    for page_name in SystemPages:
+        master = Page(request, page_name)
+        translated = Page(request, _(page_name))
+        data.addRow((master.link_to(request, page_name), translated.link_to(request, _(page_name))))
+
+    table = DataBrowserWidget(request)
+    table.setData(data)
+
+    msg = ''.join(table.format(method='GET'))
+    msg = "Help pages and their translations %s" % msg
+    if msg:
+        request.theme.add_msg(msg, "info")
+    Page(request, pagename).send_page()