Package web2py :: Package gluon :: Module languages :: Class translator
[hide private]
[frames] | no frames]

Class translator

source code

object --+
         |
        translator

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

:
   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

notice 1: there is no need to force since, by default, T uses accept_language to determine a translation file.

notice 2: en and en-en are considered different languages!

Instance Methods [hide private]
 
__init__(self, request)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
get_possible_languages(self) source code
 
set_current_languages(self, *languages) source code
 
force(self, *languages) source code
 
__call__(self, message, symbols={}, language=1) source code
 
translate(self, message, symbols)
user ## 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)
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, request)
(Constructor)

source code 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Overrides: object.__init__
(inherited documentation)

translate(self, message, symbols)

source code 

user ## 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 to allow markmin syntax to be translated