RE: [Zope] Could Someone Clean This DTML Up?
At 02:18 PM 1/6/2003 -0500, you wrote:
[ beno]
Okay, well here's what I've got right now...
<dtml-let lang="REQUEST.get('HTTP_ACCEPT_LANGUAGE')"> <dtml-in objectsInTheFolder> <dtml-if id=="&dtml-lang;"> <dtml-let approved="&dtml-lang;"> <dtml-var approved> </dtml-let> <dtml-else> <dtml-let approved="en"> <dtml-var approved> </dtml-let> </dtml-if> </dtml-in> </dtml-let>
Beno, start simple. You can get everything else working, then deal with objectsInTheFolder -
<dtml-let lang="REQUEST['HTTP_ACCEPT_LANGUAGE']"> <dtml-in "[1,2,3]"> <!-- a simple array just for testing--> <dtml-if "id==lang"> <dtml-var lang> <dtml-else> en </dtml-if> <br> </dtml-in> </dtml-let>
Bear in mind that "lang" is not going to be just "en" or whatever, and a basic "en' may occur in several variations. You will probably want to do some string processing on it before doing your comparison.
I presume that you will want to call some function or script - you were talking about a redirect earlier. In that case, replace <dtml-var lang> with <dtml-call "your_script(lang)">, and replace "en" with something like <dtml-call "another_script("en"), or use dtml-var if you want something to be displayed on the page.
Well, actually, no. What I'm building is a product for people who are new to Zope that want a quick, easy template for building "brochureware" sites, one that will also serve as a tutorial. In such sites, the content rarely changes and it isn't too much to deal with anyway. There are good Zope products out there that do translation that people who need industrial strength can use ;) I got the folder thing taken care of ;) Thanks, beno
beno wrote:
At 02:18 PM 1/6/2003 -0500, you wrote:
Bear in mind that "lang" is not going to be just "en" or whatever, and a basic "en' may occur in several variations. You will probably want to do some string processing on it before doing your comparison.
Well, actually, no. What I'm building is a product for people who are new to Zope that want a quick, easy template for building "brochureware" sites, one that will also serve as a tutorial. In such sites, the content rarely changes and it isn't too much to deal with anyway. There are good Zope products out there that do translation that people who need industrial strength can use ;)
Well, the problem is that your code won't work in a lot of cases. This isn't about industrial strength, it's about getting even a working prototype. This is what my browser sends for that header: en-us, de;q=0.50 If you haven't configured the browser, it may send nothing for that header. I'd at least do something like try: lang = context.REQUEST['HTTP_ACCEPT_LANGUAGE'][0:2] except: lang = 'en' in a python script. cheers, oliver
participants (2)
-
beno -
Oliver Bleutgen