Hi Richard,

Translations get a little more complicated than most people expect.
Here are a few things you want to watch out for:

Your site will have a default language. This is the language of the
strings placed in the T functions. Generally speaking most people
choose English simply because most web applications, including Web2py,
where programmed in english and use T with English strings throughout.
So even though I am doing a site for mostly Francophones, my "default"
site language is English. Usually you would place something like the
following in db.py for this purpose

Language Switching. Many multilingual sites need to have a mecanisim
in order to allow users to change the default language of the site
content in addition to the sites functional language. This can be
accomplished via a controller and something like the following at the
top of db.py (just under the first line is generally a good place)

#######################################################################
## Internationalization
## Requires a controller, view and menu item to allow users to change
languages on the
## fly.
######################################################################
# T.current_languages=['en','en-us'] is our applications default
language. Generally
# speaking you may want this to be English, even for sites that are
not "in english".
# This represents the language of the stings that get translated using
the "T".
T.current_languages=['en','en-us']
# If I (or a user) calls with a request var _language then we want to
store it.
if request.vars._language:
    session._language=request.vars._language
#
if session._language: T.force(session._language)

Allowing Users to change languages

Menu item example

<a href="{{=URL(r=request,c='language',f='aria_lang_index')}}"
"accesskey="l"">{{=T('language')}} : {{=session._language}}</a>






db.define_table('page',
    Field('title'),
    Field('body', 'text'),
    Field('created_on', 'datetime', default=request.now),
    Field('created_by', db.auth_user, default=user_id),
    Field('active', 'boolean'),
    Field('language'))



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