Attachment 'SystemPages.py'
Download 1 # -*- coding: iso-8859-1 -*-
2 """
3 MoinMoin - SystemPages
4
5 shows a table of System Pages and their translations to the users language
6 if the user lang is anything else than en
7
8 @copyright: 2009 MoinMoin:ReimarBauer
9 @license: GNU GPL, see COPYING for details.
10 """
11
12 from MoinMoin import i18n
13 from MoinMoin.Page import Page
14 from MoinMoin.util.dataset import TupleDataset, Column
15 from MoinMoin.widget.browser import DataBrowserWidget
16
17
18 def macro_SystemPages(macro):
19 request = macro.request
20 _ = request.getText
21
22 users_lang = i18n.requestLanguage(request)
23 if users_lang == "en":
24 return ""
25
26 domain = 'MoinMoin'
27 lang_file = i18n.po_filename(request, language=users_lang, domain=domain)
28
29 from MoinMoin.i18n.msgfmt import MsgFmt
30 lines = file(lang_file).readlines()
31 mf = MsgFmt()
32 mf.read_po(lines)
33
34 SystemPages = [key for key in mf.messages.keys() if Page(request, key).exists()]
35
36 data = TupleDataset()
37 data.columns = [
38 Column('en', label=_('Developer language')),
39 Column(users_lang, label=_('Preferred language')),
40 ]
41
42 for page_name in SystemPages:
43 master = Page(request, page_name)
44 translated = Page(request, _(page_name))
45 data.addRow((master.link_to(request, page_name), translated.link_to(request, _(page_name))))
46
47 table = DataBrowserWidget(request)
48 table.setData(data)
49
50 html = ''.join(table.format(method='GET'))
51 return html
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.