1

I have a countries.py module living in my web2py applications module folder. It defines the following tuple:

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')), 
    ...

Which can be use to create country drop down list. The problem I have is I get an error:

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

So how can I use the translator T from a web2py module?

User
  • 62,498
  • 72
  • 186
  • 247

1 Answers1

4

Based on this post in the google group:

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

I added

from gluon import current
T = current.T

to the top of my countries.py module and it seems to be working now.

User
  • 62,498
  • 72
  • 186
  • 247