annotate MoinMoin/macro/GetText2.py @ 1331:b7352ce35900

Fix GetText2 for incorrect parameters.
author Alexander Schremmer <alex AT alexanderweb DOT de>
date Sat, 19 Aug 2006 21:06:53 +0200
parents a36c70e5f0dd
children c907c2942372
rev   line source
1320
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
2 """
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
3 MoinMoin - Load I18N Text and substitute data.
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
4
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
5 This macro has the main purpose of being used by extensions that write
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
6 data to wiki pages but want to ensure that it is properly translated.
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
7
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
8 @copyright: 2006 by MoinMoin:AlexanderSchremmer
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
9 @license: GNU GPL, see COPYING for details.
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
10 """
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
11
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
12 from MoinMoin import wikiutil
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
13 from MoinMoin.packages import unpackLine
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
14
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
15 Dependencies = ["language"]
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
16
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
17 def execute(macro, args):
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
18 """ args consists of a character specifiying the separator and then a
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
19 packLine sequence describing a list. The first element of it is the message
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
20 and the remaining elements are substituted in the message using string
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
21 substitution.
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
22 """
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
23 sep = args[0]
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
24 args = unpackLine(args[1:], sep)
1331
b7352ce35900 Fix GetText2 for incorrect parameters.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1320
diff changeset
25 if args:
b7352ce35900 Fix GetText2 for incorrect parameters.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1320
diff changeset
26 translation = macro.request.getText(args[0], formatted=False)
b7352ce35900 Fix GetText2 for incorrect parameters.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1320
diff changeset
27 else:
b7352ce35900 Fix GetText2 for incorrect parameters.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1320
diff changeset
28 translation = u""
1320
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
29 message = translation % tuple(args[1:])
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
30
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
31 return macro.formatter.text(message)
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
32