Yes but... If you do something like
{{for record in db(...).select():}}{{=T(record.field}}{{pass}} you get a lot of data added dynamically to the translation files. It may slow down your app if the db data changes often. It may also result in lots of data not being translated. Two options are 1) have different record in db for different languages are do not use T 2) use plugin_translate http://www.web2py.com/plugins/default/translate Massimo On Apr 9, 7:22 pm, Stifan Kristi <steve.van.chris...@gmail.com> wrote: > Hi, > > is it possible to translate the output data table using T()? > > thank you so much > > > > > > > > On Sun, Apr 10, 2011 at 5:45 AM, niknok <nikolai...@gmail.com> wrote: > > Beautiful one liner. I have to write an ugly hack to make it work. I > > was forcing the translations because I need to translate certain > > sections only. > > > def babel(lang, s): > > # forced translation of Q&A section > > T.force(lang) > > if type(s)==list: > > loc_string=[] > > for i in s: > > loc_string.append(str(T(i))) > > else: > > loc_string=str(T(s)) > > T.set_current_languages('en') # reset to English > > return loc_string > > > and in my controller: > > > my_dialog=babel(session.locale, question['dialog']) > > my_choices=babel(session.locale, question['choices']) > > form=SQLFORM.factory( > > Field('english', writable=False, default=question['dialog']), > > Field('translation', writable=False, default=my_dialog, > > label=settings.locale[session.locale]), > > Field('answer','list:string', > > default=answer_value, > > requires=IS_IN_SET(question['choices'], my_choices, > > zero=None, > > multiple=True))) > > > On Apr 7, 9:43 pm, DenesL <denes1...@yahoo.ca> wrote: > > > Assuming > > > options = a retrieved list:string record > > > > then > > > choices = dict([(x,T(x)) for x in options]) > > > > should work. Note: untested. > > > > On Apr 7, 3:29 am,niknok<nikolai...@gmail.com> wrote: > > > > > Thanks DenesL. > > > > > What if the options are retrieved from a field of list:string type? > > > > > On Apr 4, 10:39 pm, DenesL <denes1...@yahoo.ca> wrote: > > > > > > Use > > > > > > choices = {'Gold':T('Gold'), 'Silver':T('Silver')} > > > > > > and update your language translations strings. > > > > > Not sure how "answer" is obtained. > > > > > > On 4 abr, 09:16,niknok<nikolai...@gmail.com> wrote: > > > > > > > I tried: > > > > > > Field('color', 'list:string', default=answer, > > > > > > requires=IS_IN_SET(T(question['choices']), zero=None, > > multiple=True)) > > > > > > > I would like to display the choices in the translated language but > > the > > > > > > selection will be stored in the database in the orginal language. > > For > > > > > > example: > > > > > > > choices = ['Gold', 'Silver'] > > > > > > What the user sees: ['Oro', 'Plata'] > > > > > > What is stored in the database (as the case, maybe): |Gold|Silver| > > > > > > > And if I need to display the selection (default=answer), Oro and > > Plata > > > > > > will be re-selected.