Whoops, I pressed send by accident...

Anyway you can checkout:

http://kenai.com/projects/universalcake/

for an example of the language changing mechanism.

As far as the database, you will have a record id (the automatic
index) but you may require a semi-unique field that ties all your
translations of one source document together. I use the title.

db.define_table('page',
    Field('title'),
    Field('section_id', db.section),
    Field('body', 'text'),
    Field('created_on', 'datetime', default=request.now),
    Field('created_by', db.auth_user, default=user_id),
    Field('active', 'boolean'),
    Field('language'))         # Field for language (ie. en for
example)

Selecting entires

Controller examples:
wiki.py

def show_active():
    pages = db(db.page.active=='True').select(db.page.id,
db.page.title, orderby=db.page.title)

    return dict(pages=pages)

def show_english():
    pages = db(db.page.language=='en').select(db.page.id,
db.page.title, orderby=db.page.title)
    return dict(pages=pages)

def show_active_english():
    pages = db((db.page.active=='True') &
(db.page.language=='en')).select(db.page.id, db.page.title,
orderby=db.page.title)
    return dict(pages=pages)

View example
wiki/show_active_english

{{extend 'layout.html'}}
<h1>Show Active English Pages</h1>
[ {{=A('search', _href=URL(r=request, f='search'))}} ]<br />
<ul>{{for page in pages:}}
    {{=LI(A(page.title, _href=URL(r=request, f='show', args=page.id)
        ))}}
{{pass}}</ul>
[ {{=A('create page', _href=URL(r=request, f='create'))}} ]


Don't know where you want to deploy, I think the above would run GAE,
have not tested it though...

Cheers,

Chris


On Jan 28, 3:28 am, weheh <richard_gor...@verizon.net> wrote:
> I haven't really worked with translation, yet. But I'm going to be
> getting into it in a big way. I have
>
> db.define_table('content',Field('title'),Field('body'))
>
> I want to enter title and body in English, but then translate to other
> languages.
> Let's say I do this:
>
> rows=db(db.content.id>0).select()
> for row in rows:
>   trans_title=T(row.title)
>   trans_body=T(row.body)
>
> Will something like that work?

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.

Reply via email to