My goal is the following :

If I make a SQL/CRUD form for a person object,
then the third attribute to set is the size.
I have to choose the value from a selection list.
(IS_IN_DB(db,'size.name'))

In the selection list, I can't get the translated values.
Unfortunately, that is exactly what I want.

Translating the values from the table "list", is not a problem.

For instance with the following function, I can show the translated value
on a page.

rows=db(db.size.id>0).select()
for row in rows:
   content=T('row.name')
   return content

But how can I get the translated values in the selection list ?


Thanks for your help

Op 26 december 2011 20:00 schreef Alexandre Andrade <
[email protected]> het volgende:

> T('mycontent') is the function for translation in web2py.
>
> You can throw the content of a field to it
>
> content = T(row.contentfield)
>
> and it will appear at translation files to translate.
>
> Since u apply it just to a few fields/rows/tables, it can work fine.
>
> But for large contents, you will need a tool/api to automate translation,
> and use a function to call it.
>
>
> Alexandre Andrade
>
>
> 2011/12/26 Mathias Van Daele <[email protected]>
>
>> Hey Anthony, thanks for your answer !
>>
>> Your solution for question 1 working fine !  (with label)
>> For questions 2 I am still trying...
>>
>> Mathias
>>
>>
>> Op 26 december 2011 19:06 schreef Anthony <[email protected]> het
>> volgende:
>>
>>  Concerning question 1 : How can I translate
>>>> "name_father","name_mother",..**. in a form from this table ?
>>>>
>>>
>>> Field() takes a "label" argument, which I think you should be able to
>>> translate:
>>>
>>> Field('name_father', ..., label=T('Father Name'))
>>>
>>> If that doesn't work, try T('Father Name', lazy=False), which
>>> immediately translates and returns a string.
>>>
>>>
>>>>
>>>> Concerning question 2 : Suppose table "size" contains some values like
>>>> "big","small"...
>>>> I am looking for a function to get these values translated too.
>>>>
>>>
>>> In places where you display results, you could put the outputs inside
>>> T(), as usual. I haven't tried it, but using the field's "represent"
>>> attribute (
>>> http://web2py.com/books/default/chapter/29/6#Record-representation) or
>>> a virtual field (
>>> http://web2py.com/books/default/chapter/29/6#New-style-virtual-fields-(experimental))
>>> might work as well, depending on what you're doing.
>>>
>>> Anthony
>>>
>>
>>
>
>
> --
> Atenciosamente
>
>
> Alexandre Andrade
> Hipercenter.com Classificados Gratuitos
>

Reply via email to