문제

How to use T.force('ar') to allow the system support multiple language.

i have two links into my page when Arabic link is pressed the system will converted to Arabic version and also when English link is pressed the system will converted to English version.

how to force language on click of link??

and also how can i allow data into database to be translated using "T"

Thanks in advance

도움이 되었습니까?

해결책

In web2py. Make a model that contains something like

if re.compile('\w{2}(\-\w{2})?').match(request.vars.force_language or ''): 
    session.forced_language=force_language
if session.forced_language:
   T.force(session.forced_language)

the call any of the page with

http://....../index?force_language=ar

The system will store it in session and remember your preference. Will translate if languages/ar.py exists.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top