/ / Come usare T per tradurre le stringhe nel modulo web2py? - traduzione, web2py, moduli web2py

Come usare T per tradurre le stringhe nel modulo web2py? - traduzione, web2py, moduli web2py

Ho un modulo countries.py che vive nella mia cartella del modulo applicazioni web2py. Definisce la seguente tupla:

COUNTRIES = (
("AF", T("Afghanistan")),
("AX", T("Aland Islands")),
("AL", T("Albania")),
("DZ", T("Algeria")),
("AS", T("American Samoa")),
("AD", T("Andorra")),
("AO", T("Angola")),
("AI", T("Anguilla")),
...

Quale può essere utilizzato per creare un elenco a discesa Paese. Il problema che ho è che ottengo un errore:

<type "exceptions.NameError"> name "T" is not defined

Quindi, come posso usare il traduttore T da un modulo web2py?

risposte:

3 per risposta № 1

In base a questo post nel gruppo di google:

https://groups.google.com/forum/#!topic/web2py/cHSKbhbcSSA

Ho aggiunto

from gluon import current
T = current.T

all'inizio del mio modulo countries.py e sembra che funzioni adesso.