Allow the system to support multiple languages

How to use T.force ('ar') to make the system support multiple languages.

I have two links to my page, when the Arabic link is clicked, the system will be converted to the Arabic version, and also when the English link is clicked, the system will convert to the English version.

how to force language on click of link

and also how can data be passed to database using "T"

Thank you in advance

+2


source to share


1 answer


In web2py. Create a model containing 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)

      

calling any page with



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

      

The system will store it in the session and remember your preferences. Will translate if languages โ€‹โ€‹/ ar.py exist.

+1


source







All Articles