hello
I have a similar problem except it goes for only one table - no parent -
child relationship
db.define_table('config',
Field('co_code', type = 'string', length = 256 ,label =
T('Code')),
Field('co_organization','reference organizations' ,label =
T('Organization')),
Field('co_value', type = 'string', length = 256 ,label =
T('Value')),
Field('co_area', type = 'string', length = 256 ,label =
T('Area')),
Field('co_note',type = 'text' ,label = T('Note')),
Field('co_access_level',type = 'integer'),
migrate = settings.migrate,
fake_migrate=settings.fake_migrate,
)
I would like to translate values from co_note.
Different variations of your suggested answer do not work
db.config.represent = lambda v, r: T(db.config[v])
db.config.represent = lambda v, r: T(db.config[v].co_note)
Any suggestions? I do have translations already in my language.py file
On Thursday, July 30, 2015 at 9:38:01 AM UTC+2, Massimiliano wrote:
>
> Have you tried?
>
> db.cake.fruit.represent = lambda v, r: T(db.fruits[v].name)
> grid=SQLFORM.grid(db.cake)
>
>
> On Thu, Jul 30, 2015 at 8:55 AM, Gael Princivalle <[email protected]
> <javascript:>> wrote:
>
>> Hello all.
>>
>> Is it possible to translate data in SQLFORM.grid?
>>
>> MODEL:
>> db.define_table('fruits',
>> Field('name', type='string'),
>> format='%(name)s')
>>
>> db.define_table('cake',
>> Field('name', type='string'),
>> Field('fruit', 'reference fruits', requires = IS_IN_DB(db
>> , db.fruits.id, '%(name)s'), represent=lambda id, r: db.fruits[id].name))
>>
>> CONTROLLER:
>> grid=SQLFORM.grid(db.cake)
>>
>> VIEW:
>> {{=grid}}
>>
>> In the fruits table, names are in english, for example "Apple".
>>
>> Is it possible to set for this field in the grid automatic traductions
>> like T()?
>>
>> In this case for example I would like to have in an Italian page "Mela"
>> instead of "Apple".
>>
>> Thanks.
>>
>> --
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Massimiliano
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.