Log in |
Create Multilanguage ApplicationMake your Zope product available in a lot of languages.All you need is to translate your messages in different languages. Create two tiny tables and a python script: Tiny table Id: languages Columns: name descr Data: "romanian", "Limba Romana" "english", "English language" "chineze", "Chineza" "japoneza", "Limba Japoneza" Tiny table Id: messages Columns: msgid romanian english Data: "1","something in romanian","something in english" "2","ceva","something" "3","casa","home" "sav","Salvare date","Save data" Script (Python) Id: msg Parameter List: msgid Body: ret='(unknown) ix='+str(msgid) for i in context.messages(msgid=str(msgid)): try: ret=getattr(i,context.REQUEST.language) except: ret='(unknown) ('+i.english+')' break return ret How do you use this ?Create a DTML Method or Document with body like: <dtml-unless language><dtml-call "REQUEST.set('language','english')"></dtml-unless> <form name="selectlanguage"> <select name="language" onchange="document.selectlanguage.submit();"> <dtml-in languages><option value="&dtml-name;" <dtml-if "language==name"> selected</dtml-if>>&dtml-descr;</option></dtml-in> </select> <input type="submit" value="!"> </form>Then insert <dtml-var "msg(1)"> where you want to display message #1 or <dtml-var "msg('sav')"> where you display button 'save'. If no language is selected, default will be 'english' because of <dtml-unless language><dtml-call "REQUEST.set('language','english')"></dtml-unless> After you select the language, the current page will be reloaded and you'll see it in other language. |