Back to index

plone3  3.1.7
Public Member Functions | Static Public Attributes | Static Private Attributes
CMFPlone.TranslationServiceTool.TranslationServiceTool Class Reference
Inheritance diagram for CMFPlone.TranslationServiceTool.TranslationServiceTool:
Inheritance graph
[legend]
Collaboration diagram for CMFPlone.TranslationServiceTool.TranslationServiceTool:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def utranslate
def encode
def asunicodetype
def ulocalized_time
def day_msgid
def month_msgid
def month_english
def month
def weekday_english

Static Public Attributes

string id = 'translation_service'
 meta_type = ToolNames.TranslationServiceTool
string toolicon = 'skins/plone_images/site_icon.gif'
tuple security = ClassSecurityInfo()

Static Private Attributes

tuple __implements__

Detailed Description

Utility methods to access the translation machinery 

Definition at line 24 of file TranslationServiceTool.py.


Member Function Documentation

def CMFPlone.TranslationServiceTool.TranslationServiceTool.asunicodetype (   self,
  m,
  input_encoding = None,
  errors = 'strict' 
)

Definition at line 60 of file TranslationServiceTool.py.

00060 
00061     def asunicodetype(self, m, input_encoding=None, errors='strict'):
00062         # create type unicode from type string
00063 
00064         if isinstance(m, unicode): return m
00065 
00066         if input_encoding is None:
00067             # get input encoding from portal
00068             plone_tool = getToolByName(self, 'plone_utils')
00069             input_encoding = plone_tool.getSiteEncoding()
00070 
00071         # return as type unicode
00072         return unicode(str(m), input_encoding, errors)

Here is the call graph for this function:

def CMFPlone.TranslationServiceTool.TranslationServiceTool.day_msgid (   self,
  number,
  format = None 
)
Returns the msgid which can be passed to the translation service for
l10n of weekday names. Format is either None, 'a' or 's'.

>>> ttool = TranslationServiceTool()

>>> ttool.day_msgid(0)
'weekday_sun'

>>> ttool.day_msgid(6)
'weekday_sat'

>>> ttool.day_msgid(0, format='a')
'weekday_sun_abbr'

>>> ttool.day_msgid(3, format='s')
'weekday_wed_short'

Definition at line 82 of file TranslationServiceTool.py.

00082 
00083     def day_msgid(self, number, format=None):
00084         """ Returns the msgid which can be passed to the translation service for
00085         l10n of weekday names. Format is either None, 'a' or 's'.
00086 
00087         >>> ttool = TranslationServiceTool()
00088 
00089         >>> ttool.day_msgid(0)
00090         'weekday_sun'
00091 
00092         >>> ttool.day_msgid(6)
00093         'weekday_sat'
00094 
00095         >>> ttool.day_msgid(0, format='a')
00096         'weekday_sun_abbr'
00097 
00098         >>> ttool.day_msgid(3, format='s')
00099         'weekday_wed_short'
00100         """
00101         # 
00102         if format == 's':
00103             # short format
00104             method = weekdayname_msgid_short
00105         elif format == 'a':
00106             # abbreviation
00107             method = weekdayname_msgid_abbr
00108         else:
00109             # long format
00110             method = weekdayname_msgid
00111         return method(number)

def CMFPlone.TranslationServiceTool.TranslationServiceTool.encode (   self,
  m,
  input_encoding = None,
  output_encoding = None,
  errors = 'strict' 
)

Definition at line 43 of file TranslationServiceTool.py.

00043 
00044     def encode(self, m, input_encoding=None, output_encoding=None, errors='strict'):
00045         # encode a give unicode type or string type to string type in encoding output_encoding
00046 
00047         # check if input is not type unicode
00048         if not isinstance(m, unicode):
00049             if input_encoding is None: input_encoding = 'utf-8'
00050             m = unicode(str(m), input_encoding, errors)
00051 
00052         if output_encoding is None:
00053             # get output encoding from portal
00054             plone_tool = getToolByName(self, 'plone_utils')
00055             output_encoding = plone_tool.getSiteEncoding()
00056 
00057         # return as type string
00058         return m.encode(output_encoding, errors)

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFPlone.TranslationServiceTool.TranslationServiceTool.month (   self,
  number,
  format = None,
  default = None 
)
Returns a Message with the month name, that can be translated by
the TAL engine. Format is either None or 'a' (long or abbreviation).

Definition at line 146 of file TranslationServiceTool.py.

00146 
00147     def month(self, number, format=None, default=None):
00148         """ Returns a Message with the month name, that can be translated by
00149         the TAL engine. Format is either None or 'a' (long or abbreviation).
00150         """
00151         if default is None:
00152             default = monthname_english(number, format=format)
00153         value = 'a' == format and monthname_msgid_abbr(number) or monthname_msgid(number)
00154         return PLMF(value, default=default)

Here is the call graph for this function:

def CMFPlone.TranslationServiceTool.TranslationServiceTool.month_english (   self,
  number,
  format = None 
)
Returns the english name of month by number. Format is either '' or
'a' (long or abbreviation).

>>> ttool = TranslationServiceTool()

>>> ttool.month_english(1)
'January'

>>> ttool.month_english(1, 'a')
'Jan'

Definition at line 131 of file TranslationServiceTool.py.

00131 
00132     def month_english(self, number, format=None):
00133         """ Returns the english name of month by number. Format is either '' or
00134         'a' (long or abbreviation).
00135 
00136         >>> ttool = TranslationServiceTool()
00137 
00138         >>> ttool.month_english(1)
00139         'January'
00140 
00141         >>> ttool.month_english(1, 'a')
00142         'Jan'
00143         """
00144         return monthname_english(number, format=format)

Here is the call graph for this function:

def CMFPlone.TranslationServiceTool.TranslationServiceTool.month_msgid (   self,
  number,
  format = None 
)
Returns the msgid which can be passed to the translation service for
l10n of month names. Format is either '' or 'a' (long or abbreviation).

>>> ttool = TranslationServiceTool()

>>> ttool.month_msgid(1)
'month_jan'

>>> ttool.month_msgid(12)
'month_dec'

>>> ttool.month_msgid(6, format='a')
'month_jun_abbr'

Definition at line 113 of file TranslationServiceTool.py.

00113 
00114     def month_msgid(self, number, format=None):
00115         """ Returns the msgid which can be passed to the translation service for
00116         l10n of month names. Format is either '' or 'a' (long or abbreviation).
00117 
00118         >>> ttool = TranslationServiceTool()
00119 
00120         >>> ttool.month_msgid(1)
00121         'month_jan'
00122 
00123         >>> ttool.month_msgid(12)
00124         'month_dec'
00125 
00126         >>> ttool.month_msgid(6, format='a')
00127         'month_jun_abbr'
00128         """
00129         return 'a' == format and monthname_msgid_abbr(number) or monthname_msgid(number)

Here is the call graph for this function:

def CMFPlone.TranslationServiceTool.TranslationServiceTool.ulocalized_time (   self,
  time,
  long_format = None,
  context = None,
  domain = 'plonelocales',
  request = None 
)

Definition at line 75 of file TranslationServiceTool.py.

00075 
00076                         domain='plonelocales', request=None):
00077         # get some context if none is passed
00078         if context is None:
00079             context = self
00080         return ulocalized_time(time, long_format, context, domain, request)

Here is the caller graph for this function:

Definition at line 37 of file TranslationServiceTool.py.

00037 
00038     def utranslate(self, *args, **kw):
00039         # Translate method to access the translation service
00040         # from resticted code like skins.
00041         return utranslate(*args, **kw)

def CMFPlone.TranslationServiceTool.TranslationServiceTool.weekday_english (   self,
  number,
  format = None 
)
Returns the english name of a week by number. Format is either None,
'a' or 'p'.

>>> ttool = TranslationServiceTool()

>>> ttool.weekday_english(0)
'Sunday'

>>> ttool.weekday_english(6)
'Saturday'

>>> ttool.weekday_english(0, format='a')
'Sun'

>>> ttool.weekday_english(3, format='p')
'Wed.'

Definition at line 156 of file TranslationServiceTool.py.

00156 
00157     def weekday_english(self, number, format=None):
00158         """ Returns the english name of a week by number. Format is either None,
00159         'a' or 'p'.
00160 
00161         >>> ttool = TranslationServiceTool()
00162 
00163         >>> ttool.weekday_english(0)
00164         'Sunday'
00165 
00166         >>> ttool.weekday_english(6)
00167         'Saturday'
00168 
00169         >>> ttool.weekday_english(0, format='a')
00170         'Sun'
00171 
00172         >>> ttool.weekday_english(3, format='p')
00173         'Wed.'
00174         """
00175         return weekdayname_english(number, format=format)
00176 
00177 InitializeClass(TranslationServiceTool)

Here is the call graph for this function:


Member Data Documentation

Initial value:
(PloneBaseTool.__implements__,
                      SimpleItem.__implements__, )

Definition at line 33 of file TranslationServiceTool.py.

string CMFPlone.TranslationServiceTool.TranslationServiceTool.id = 'translation_service' [static]

Definition at line 27 of file TranslationServiceTool.py.

Definition at line 28 of file TranslationServiceTool.py.

Definition at line 30 of file TranslationServiceTool.py.

string CMFPlone.TranslationServiceTool.TranslationServiceTool.toolicon = 'skins/plone_images/site_icon.gif' [static]

Definition at line 29 of file TranslationServiceTool.py.


The documentation for this class was generated from the following file: