Trees | Index | Help |
|
---|
Package zope :: Package i18nmessageid :: Module messageid :: Class MessageID |
|
object
--+ |basestring
--+ |unicode
--+ | MessageID
Message ID.
This is a string used as a message ID. It has a domain attribute that is its source domain, and a default attribute that is its default text to display when there is no translation. domain may be None meaning there is no translation domain. default may also be None, in which case the message id itself implicitly serves as the default text.
MessageID objects also have a mapping attribute which must be set after construction of the object. This is used when translating and substituting variables.
To instanciate MessageIDs, it is recommended to use MessageIDFactory:
>>> fact = MessageIDFactory('test')
Now we can use the factory to make MessageIDs. Note that MessageID is
a subclass of unicode:
>>> id = fact(u'this is a test') >>> isinstance(id, MessageID) True >>> isinstance(id, unicode) TrueAdditional parameters, such as the i18n domain and the default text are available through attributes:
>>> id.domain 'test' >>> id.default u'this is a test'You can also reset the default text:
>>> id.default = u'blah' >>> id.default u'blah'It is quite common to pass an abstract identifier as message id and then a default text:
>>> id = fact(u'test-id', 'default test') >>> id u'test-id' >>> id.default u'default test' >>> id.domain 'test'
Method Summary | |
---|---|
__getstate__(self)
| |
__new__(cls,
ustr,
domain,
default)
(Static method) | |
__setstate__(self,
(ustr,
domain,
default,
mapping))
| |
Inherited from unicode | |
x.__add__(y) <==> x+y | |
x.__cmp__(y) <==> cmp(x,y) | |
x.__contains__(y) <==> y in x | |
x.__getattribute__('name') <==> x.name | |
x.__getitem__(y) <==> x[y] | |
| |
Use of negative indices is not supported. | |
x.__hash__() <==> hash(x) | |
x.__len__() <==> len(x) | |
x.__mod__(y) <==> x%y | |
x.__mul__(n) <==> x*n | |
x.__repr__() <==> repr(x) | |
x.__rmod__(y) <==> y%x | |
x.__rmul__(n) <==> n*x | |
x.__str__() <==> str(x) | |
Return a capitalized version of S, i.e. | |
Return S centered in a Unicode string of length width. | |
Return the number of occurrences of substring sub in Unicode string S[start:end]. | |
Decodes S using the codec registered for encoding. | |
Encodes S using the codec registered for encoding. | |
Return True if S ends with the specified suffix, False otherwise. | |
Return a copy of S where all tab characters are expanded using spaces. | |
Return the lowest index in S where substring sub is found, such that sub is contained within s[start,end]. | |
Like S.find() but raise ValueError when the substring is not found. | |
Return True if all characters in S are alphanumeric and there is at least one character in S, False otherwise. | |
Return True if all characters in S are alphabetic and there is at least one character in S, False otherwise. | |
Return True if there are only decimal characters in S, False otherwise. | |
Return True if all characters in S are digits and there is at least one character in S, False otherwise. | |
Return True if all cased characters in S are lowercase and there is at least one cased character in S, False otherwise. | |
Return True if there are only numeric characters in S, False otherwise. | |
Return True if all characters in S are whitespace and there is at least one character in S, False otherwise. | |
Return True if S is a titlecased string and there is at least one character in S, i.e. | |
Return True if all cased characters in S are uppercase and there is at least one cased character in S, False otherwise. | |
Return a string which is the concatenation of the strings in the sequence. | |
Return S left justified in a Unicode string of length width. | |
Return a copy of the string S converted to lowercase. | |
Return a copy of the string S with leading whitespace removed. | |
S.replace (old, new[, maxsplit]) -> unicode | |
Return the highest index in S where substring sub is found, such that sub is contained within s[start,end]. | |
Like S.rfind() but raise ValueError when the substring is not found. | |
Return S right justified in a Unicode string of length width. | |
Return a list of the words in S, using sep as the delimiter string, starting at the end of the string and working to the front. | |
Return a copy of the string S with trailing whitespace removed. | |
Return a list of the words in S, using sep as the delimiter string. | |
S.splitlines([keepends]]) -> list of strings | |
Return True if S starts with the specified prefix, False otherwise. | |
Return a copy of the string S with leading and trailing whitespace removed. | |
Return a copy of S with uppercase characters converted to lowercase and vice versa. | |
Return a titlecased version of S, i.e. | |
Return a copy of the string S, where all characters have been mapped through the given translation table, which must be a mapping of Unicode ordinals to Unicode ordinals, Unicode strings or None. | |
Return a copy of S converted to uppercase. | |
Pad a numeric string x with zeros on the left, to fill a field of the specified width. | |
Inherited from object | |
x.__init__(...) initializes x; see x.__class__.__doc__ for signature | |
x.__delattr__('name') <==> del x.name | |
helper for pickle | |
helper for pickle | |
x.__setattr__('name', value) <==> x.name = value |
Class Variable Summary | |
---|---|
tuple |
__slots__ = ('domain', 'default', 'mapping')
|
member_descriptor |
default = <member 'default' of 'MessageID' objects>
|
member_descriptor |
domain = <member 'domain' of 'MessageID' objects>
|
member_descriptor |
mapping = <member 'mapping' of 'MessageID' objects>
|
Class Variable Details |
---|
__slots__
|
default
|
domain
|
mapping
|
Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Fri Jun 24 12:01:22 2005 | http://epydoc.sf.net |