Initial Commit
[Projects.git] / pkgbuilds / pytivo / pkg / usr / share / pyTivo / Cheetah / Macros / I18n.py
blob7c2b1ef7e789e96476e00af2927a77e1f283c217
1 import gettext
2 _ = gettext.gettext
3 class I18n(object):
4 def __init__(self, parser):
5 pass
7 ## junk I'm playing with to test the macro framework
8 # def parseArgs(self, parser, startPos):
9 # parser.getWhiteSpace()
10 # args = parser.getExpression(useNameMapper=False,
11 # pyTokensToBreakAt=[':']).strip()
12 # return args
14 # def convertArgStrToDict(self, args, parser=None, startPos=None):
15 # def getArgs(*pargs, **kws):
16 # return pargs, kws
17 # exec 'positionalArgs, kwArgs = getArgs(%(args)s)'%locals()
18 # return kwArgs
20 def __call__(self,
21 src, # aka message,
22 plural=None,
23 n=None, # should be a string representing the name of the
24 # '$var' rather than $var itself
25 id=None,
26 domain=None,
27 source=None,
28 target=None,
29 comment=None,
31 # args that are automatically supplied by the parser when the
32 # macro is called:
33 parser=None,
34 macros=None,
35 isShortForm=False,
36 EOLCharsInShortForm=None,
37 startPos=None,
38 endPos=None,
40 """This is just a stub at this time.
42 plural = the plural form of the message
43 n = a sized argument to distinguish between single and plural forms
45 id = msgid in the translation catalog
46 domain = translation domain
47 source = source lang
48 target = a specific target lang
49 comment = a comment to the translation team
51 See the following for some ideas
52 http://www.zope.org/DevHome/Wikis/DevSite/Projects/ComponentArchitecture/ZPTInternationalizationSupport
54 Other notes:
55 - There is no need to replicate the i18n:name attribute from plone / PTL,
56 as cheetah placeholders serve the same purpose
59 """
61 #print macros['i18n']
62 src = _(src)
63 if isShortForm and endPos<len(parser):
64 return src+EOLCharsInShortForm
65 else:
66 return src