"Fossies" - the Fresh Open Source Software Archive

Member "cheetah3-3.2.6.post2/Cheetah/Macros/I18n.py" (20 Apr 2021, 1724 Bytes) of package /linux/www/cheetah3-3.2.6.post2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "I18n.py" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 3-3.1.0_vs_3-3.2.0.

    1 import gettext
    2 _ = gettext.gettext
    3 
    4 
    5 class I18n(object):
    6     def __init__(self, parser):
    7         pass
    8 
    9     def __call__(self,
   10                  src,  # aka message,
   11                  plural=None,
   12                  # should be a string representing the name of the '$var'
   13                  # rather than $var itself
   14                  n=None,
   15                  id=None,
   16                  domain=None,
   17                  source=None,
   18                  target=None,
   19                  comment=None,
   20 
   21                  # args that are automatically supplied by the parser when the
   22                  # macro is called:
   23                  parser=None,
   24                  macros=None,
   25                  isShortForm=False,
   26                  EOLCharsInShortForm=None,
   27                  startPos=None,
   28                  endPos=None,
   29                  ):
   30         """This is just a stub at this time.
   31 
   32            plural = the plural form of the message
   33            n = a sized argument to distinguish between single and plural forms
   34 
   35            id = msgid in the translation catalog
   36            domain = translation domain
   37            source = source lang
   38            target = a specific target lang
   39            comment = a comment to the translation team
   40 
   41         See the following for some ideas
   42         http://www.zope.org/DevHome/Wikis/DevSite/Projects/ComponentArchitecture/ZPTInternationalizationSupport
   43 
   44         Other notes:
   45         - There is no need to replicate the i18n:name attribute
   46           from plone/PTL, as cheetah placeholders serve the same purpose.
   47        """
   48 
   49         # print macros['i18n']
   50         src = _(src)
   51         if isShortForm and endPos < len(parser):
   52             return src + EOLCharsInShortForm
   53         else:
   54             return src