Docs for T

[ Python Tutorial ] [ Python Libraries ] [ web2py epydoc ]

Description


<class 'gluon.languages.translator'>




















This class is instantiated by gluon.compileapp.build_environment
as the T object

Example:

T.force(None) # turns off translation
T.force('fr, it') # forces web2py to translate using fr.py or it.py

T("Hello World") # translates "Hello World" using the selected file

Note:
-
there is no need to force since, by default, T uses
http_accept_language to determine a translation file.
-
en and en-en are considered different languages!
-
if language xx-yy is not found force() probes other similar languages
using such algorithm: `xx-yy.py -> xx.py -> xx-yy*.py -> xx*.py`


Attributes


T.M <type 'instancemethod'> belongs to class <type 'instancemethod'>
Gets cached translated markmin-message with inserted parametes if lazy==True lazyT object is returned

T.__call__ <type 'instancemethod'> belongs to class <type 'instancemethod'>
get cached translated plain text message with inserted parameters(symbols) if lazy==True lazyT object is returned

T.__class__ <type 'type'> extends (<type 'object'>,) belongs to class <type 'type'>
This class is instantiated by gluon.compileapp.build_environment as the T object Example: T.force(None) # turns off translation T.force('fr, it') # forces web2py to translate using fr.py or it.py T("Hello World") # translates "Hello World" using the selected file Note: - there is no need to force since, by default, T uses http_accept_language to determine a translation file. - en and en-en are considered different languages! - if language xx-yy is not found force() probes other similar languages using such algorithm: `xx-yy.py -> xx.py -> xx-yy*.py -> xx*.py`

T.__delattr__ <type 'method-wrapper'> belongs to class <type 'method-wrapper'>
x.__delattr__('name') <==> del x.name

T.__dict__ <type 'dict'> belongs to class <type 'dict'>
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

T.__doc__ <type 'str'> belongs to class <type 'str'>
str(object='') -> string Return a nice string representation of the object. If the argument is a string, the return value is the same object.

T.__format__ <type 'builtin_function_or_method'> belongs to class <type 'builtin_function_or_method'>
default object formatter

T.__get_otherT__ <type 'instancemethod'> belongs to class <type 'instancemethod'>

T.__getattribute__ <type 'method-wrapper'> belongs to class <type 'method-wrapper'>
x.__getattribute__('name') <==> x.name

T.__hash__ <type 'method-wrapper'> belongs to class <type 'method-wrapper'>
x.__hash__() <==> hash(x)

T.__init__ <type 'instancemethod'> belongs to class <type 'instancemethod'>

T.__module__ <type 'str'> belongs to class <type 'str'>
str(object='') -> string Return a nice string representation of the object. If the argument is a string, the return value is the same object.

T.__new__ <type 'builtin_function_or_method'> belongs to class <type 'builtin_function_or_method'>
T.__new__(S, ...) -> a new object with type S, a subtype of T

T.__reduce__ <type 'builtin_function_or_method'> belongs to class <type 'builtin_function_or_method'>
helper for pickle

T.__reduce_ex__ <type 'builtin_function_or_method'> belongs to class <type 'builtin_function_or_method'>
helper for pickle

T.__repr__ <type 'method-wrapper'> belongs to class <type 'method-wrapper'>
x.__repr__() <==> repr(x)

T.__setattr__ <type 'method-wrapper'> belongs to class <type 'method-wrapper'>
x.__setattr__('name', value) <==> x.name = value

T.__sizeof__ <type 'builtin_function_or_method'> belongs to class <type 'builtin_function_or_method'>
__sizeof__() -> int size of object in memory, in bytes

T.__str__ <type 'method-wrapper'> belongs to class <type 'method-wrapper'>
x.__str__() <==> str(x)

T.__subclasshook__ <type 'builtin_function_or_method'> belongs to class <type 'builtin_function_or_method'>
Abstract classes can override this to customize issubclass(). This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

T.__weakref__ <type 'NoneType'> belongs to class <type 'NoneType'>

T.accepted_language <type 'str'> belongs to class <type 'str'>
str(object='') -> string Return a nice string representation of the object. If the argument is a string, the return value is the same object.

T.apply_filter <type 'instancemethod'> belongs to class <type 'instancemethod'>

T.cache <type 'tuple'> belongs to class <type 'tuple'>
tuple() -> empty tuple tuple(iterable) -> tuple initialized from iterable's items If the argument is a tuple, the return value is the same object.

T.construct_plural_form <type 'function'> belongs to class <type 'function'>

T.current_languages <type 'list'> belongs to class <type 'list'>
list() -> new empty list list(iterable) -> new list initialized from iterable's items

T.default_language_file <type 'str'> belongs to class <type 'str'>
str(object='') -> string Return a nice string representation of the object. If the argument is a string, the return value is the same object.

T.default_t <type 'dict'> belongs to class <type 'dict'>
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

T.filter <type 'function'> belongs to class <type 'function'>

T.force <type 'instancemethod'> belongs to class <type 'instancemethod'>
Selects language(s) for translation if a list of languages is passed as a parameter, the first language from this list that matches the ones from the possible_languages dictionary will be selected default language will be selected if none of them matches possible_languages.

T.ftag <type 'str'> belongs to class <type 'str'>
str(object='') -> string Return a nice string representation of the object. If the argument is a string, the return value is the same object.

T.get_plural_id <type 'function'> belongs to class <type 'function'>

T.get_possible_languages <type 'instancemethod'> belongs to class <type 'instancemethod'>
Gets list of all possible languages for current application

T.get_possible_languages_info <type 'instancemethod'> belongs to class <type 'instancemethod'>
Returns info for selected language or dictionary with all possible languages info from `APP/languages/*.py` It Returns: - a tuple containing:: langcode, langname, langfile_mtime, pluraldict_fname, pluraldict_mtime, prules_langcode, nplurals, get_plural_id, construct_plural_form or None - if *lang* is NOT defined a dictionary with all possible languages:: { langcode(from filename): ( langcode, # language code from !langcode! langname, # language name in national spelling from !langname! langfile_mtime, # m_time of language file pluraldict_fname,# name of plural dictionary file or None (when default.py is not exist) pluraldict_mtime,# m_time of plural dictionary file or 0 if file is not exist prules_langcode, # code of plural rules language or 'default' nplurals, # nplurals for current language get_plural_id, # get_plural_id() for current language construct_plural_form) # construct_plural_form() for current language } Args: lang (str): language

T.get_t <type 'instancemethod'> belongs to class <type 'instancemethod'>
Use ## to add a comment into a translation string the comment can be useful do discriminate different possible translations for the same string (for example different locations):: T(' hello world ') -> ' hello world ' T(' hello world ## token') -> ' hello world ' T('hello ## world## token') -> 'hello ## world' the ## notation is ignored in multiline strings and strings that start with ##. This is needed to allow markmin syntax to be translated

T.http_accept_language <type 'str'> belongs to class <type 'str'>
str(object='') -> string Return a nice string representation of the object. If the argument is a string, the return value is the same object.

T.is_writable <type 'bool'> belongs to class <type 'bool'>
bool(x) -> bool Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.

T.langpath <type 'str'> belongs to class <type 'str'>
str(object='') -> string Return a nice string representation of the object. If the argument is a string, the return value is the same object.

T.language_file <type 'str'> belongs to class <type 'str'>
str(object='') -> string Return a nice string representation of the object. If the argument is a string, the return value is the same object.

T.lazy <type 'bool'> belongs to class <type 'bool'>
bool(x) -> bool Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.

T.nplurals <type 'int'> belongs to class <type 'int'>
int(x=0) -> int or long int(x, base=10) -> int or long Convert a number or string to an integer, or return 0 if no arguments are given. If x is floating point, the conversion truncates towards zero. If x is outside the integer range, the function returns a long instead. If x is not a number or if base is given, then x must be a string or Unicode object representing an integer literal in the given base. The literal can be preceded by '+' or '-' and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int('0b100', base=0) 4

T.ns <type 'NoneType'> belongs to class <type 'NoneType'>

T.otherTs <type 'dict'> belongs to class <type 'dict'>
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

T.params_substitution <type 'instancemethod'> belongs to class <type 'instancemethod'>
Substitutes parameters from symbols into message using %. also parse `%%{}` placeholders for plural-forms processing. Returns: string with parameters Note: *symbols* MUST BE OR tuple OR dict of parameters!

T.plural <type 'instancemethod'> belongs to class <type 'instancemethod'>
Gets plural form of word for number *n* invoked from T()/T.M() in `%%{}` tag Note: "word" MUST be defined in current language (T.accepted_language) Args: word (str): word in singular n (numeric): number plural form created for Returns: word (str): word in appropriate singular/plural form

T.plural_dict <type 'dict'> belongs to class <type 'dict'>
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

T.plural_file <type 'str'> belongs to class <type 'str'>
str(object='') -> string Return a nice string representation of the object. If the argument is a string, the return value is the same object.

T.plural_language <type 'str'> belongs to class <type 'str'>
str(object='') -> string Return a nice string representation of the object. If the argument is a string, the return value is the same object.

T.requested_languages <type 'tuple'> belongs to class <type 'tuple'>
tuple() -> empty tuple tuple(iterable) -> tuple initialized from iterable's items If the argument is a tuple, the return value is the same object.

T.set_current_languages <type 'instancemethod'> belongs to class <type 'instancemethod'>
Sets current AKA "default" languages Setting one of this languages makes the force() function to turn translation off

T.t <type 'dict'> belongs to class <type 'dict'>
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

T.translate <type 'instancemethod'> belongs to class <type 'instancemethod'>
Gets cached translated message with inserted parameters(symbols)