root/galaxy-central/eggs/Cheetah-2.2.2-py2.6-macosx-10.6-universal-ucs2.egg/Cheetah/Macros/I18n.py

リビジョン 3, 2.2 KB (コミッタ: kohda, 14 年 前)

Install Unix tools  http://hannonlab.cshl.edu/galaxy_unix_tools/galaxy.html

行番号 
1import gettext
2_ = gettext.gettext
3class I18n(object):
4    def __init__(self, parser):
5        pass
6
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
13#
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
19
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,
30
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,
39             ):
40        """This is just a stub at this time.
41
42           plural = the plural form of the message
43           n = a sized argument to distinguish between single and plural forms           
44
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
50
51        See the following for some ideas
52        http://www.zope.org/DevHome/Wikis/DevSite/Projects/ComponentArchitecture/ZPTInternationalizationSupport
53
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
57   
58   
59       """
60       
61        #print macros['i18n']
62        src = _(src)
63        if isShortForm and endPos<len(parser):
64            return src+EOLCharsInShortForm
65        else:
66            return src
67       
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。