New questions about translation

55 views
Skip to first unread message

Константин Комков

unread,
Aug 2, 2019, 6:47:55 AM8/2/19
to web2py-users
Messages in flash have uncorrect translate, like on picture 1.
db.py
if auth.user_id is not None:
   
if auth.user.language is not None:
       
if auth.user.language == 1:
            T
.force('en')
       
elif auth.user.language == 2:
            T
.force('ru')
   
else:
        T
.force('ru')
else:
    T
.force('ru')


auth
.settings.extra_fields['auth_user']= [Field('language','integer',label=T('Language'))]
auth
.define_tables(username=False, signature=False)
Now if I open profile I see field language, like on picture 2. I created table 'LANGUAGES' with 'id' and 'NAME' and foreign key in table 'AUTH_USER'. How can I change field input on select with languages names?


1.png
2.png

Константин Комков

unread,
Aug 14, 2019, 5:09:16 PM8/14/19
to web2py-users
In the book I find three possible ways for that:
First it is customize auth_user table, but Massimo wrote that this way is not really recommended.
Second it is add extra_fields, but I don't know how can I add type 'list:string' for extra_field and work with it.
Third is modify profile function def myprofile(): return dict(form=auth.profile()), but for me more interesting auth.profile(), becouse I want add new field in auth.profile() form.
I hope somebody help me with it.

Константин Комков

unread,
Aug 21, 2019, 4:49:56 PM8/21/19
to web2py-users
I can do it!) I transferred table 'languages' from tables.py to db.py, becouse I need use it in extra_fields when tables.py file is not still included.
db.py
db.define_table(
   
'languages',
   
Field('NAME',length=30)
)
auth
.settings.extra_fields['auth_user']= [Field('language','reference languages',label=T('Language'),requires = IS_IN_DB(db,db.languages.id,'%(NAME)s'))]
Result was like on picture, but I want to ask why I had one empty option in select? Is there way to exclude it?  
1.png
Reply all
Reply to author
Forward
0 new messages