Attachment 'query_translation.py'
Download 1 #!/usr/bin/env python
2
3 """
4 MoinMoin - query_translations script to get po strings from existing master pages
5
6 @copyright: 2009 MoinMoin:ReimarBauer
7
8 @license: GNU GPL, see COPYING for details.
9 """
10
11 import sys, os
12
13 # a) Configuration of Python's code search path
14 # If you already have set up the PYTHONPATH environment variable for the
15 # stuff you see below, you don't need to do a1) and a2).
16
17 # a1) Path of the directory where the MoinMoin code package is located.
18 # Needed if you installed with --prefix=PREFIX or you didn't use setup.py.
19 #sys.path.insert(0, 'PREFIX/lib/python2.4/site-packages')
20
21 # a2) Path of the directory where wikiconfig.py / farmconfig.py is located.
22 moinpath = os.path.abspath(os.path.normpath(os.path.dirname(sys.argv[0])))
23 sys.path.insert(0, moinpath)
24 os.chdir(moinpath)
25
26 from MoinMoin.web.contexts import ScriptContext
27 request = ScriptContext()
28
29 from MoinMoin.i18n import strings
30 from MoinMoin.Page import Page
31
32 def lang_select():
33 """ Create language selection. """
34 from MoinMoin import i18n
35 return i18n.wikiLanguages().keys()
36
37 def underlay_pages(request, language='en'):
38 underlay_page_list = []
39 for name in request.rootpage.getPageList(exists=1):
40 page = Page(request, name)
41 if page.getPageStatus()[0] and page.pi['language'] == language:
42 # is an underlay page in the wanted language
43 underlay_page_list.append(name)
44 return underlay_page_list
45
46 for language in lang_select():
47 if language == 'en':
48 continue
49 lang_dependent = underlay_pages(request, language=language)
50 result = []
51 for name in lang_dependent:
52 if name == "MoinI18n/%s" % language:
53 continue
54 page = Page(request, name)
55 meta = page.get_meta()
56 for l, value in meta:
57 if value.startswith('master-page:'):
58 master_page = value.replace('master-page:', "").strip()
59 m_exists = Page(request, master_page).exists()
60 app_text = ""
61 if not m_exists:
62 app_text = "# check typo this master page does not exists"
63 result.append("""msgid "%s" %s
64 msgstr "%s"
65 """ % (master_page, app_text, name))
66 break
67 if result:
68 result = '\n'.join(result)
69 file('%s_po.txt' % language, 'w').write(result.encode('utf-8'))
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.