Dan Rusch writes:
We have a site that is composed of several hunderd pages. We don't use classes but we have made heavy use of aquistion though. For example we have one back button that is aquired thoughout the site etc etc. Basically if the functionality (or code) is used in more than one place it has been but into a method and aquired. Aquisition should play well with internationalization.
You would put the localization into the aquired objects. If the language information is e.g. in a cookie, you could use its value to select the various language variants of your object. If the language information is in the URL, I probably would extend the Zope folder class to a LangFolder. It would behave exactly likes a normal folder, but would add an "LANGUAGE" variable to the REQUEST object during traversal. To select the correct localization of an object, you could have language folders for each language containing the localizations for the respective language. If we assume, that all the id's are unique, DTML code similar to this can be used for selection: <dtml-with "_[LANGUAGE]"> <dtml-var "_[id]"> </dtml-with> Dieter
I only have a few internationalized pages, but I'm more than half-way happy with a very simple approach: 1) an External Method "preferred_lang", which takes a list of possible languages as argument, and returns the language from that list that has the highest ranking in HTTP_ACCEPT_LANGUAGE. If there is no hit, it returns the first language in the list. ------------------------------------ import string def preferred_lang(self,langs): for lang in map(string.strip,string.split(self.HTTP_ACCEPT_LANGUAGE,',')): if lang in langs: return lang return langs[0] ------------------------------------- This External Method is available as "PreferredLanguage" on the root folder. 2) In each internationalized page, I call the External Method with a list of the available languages (it is not the same for all pages), and then select the contents based on the result. ------------------------------------ <dtml-var standard_html_header> <dtml-call "REQUEST.set('lang',PreferredLanguage(REQUEST,['en','nl']))"> <dtml-if "lang=='nl'"> <H2>De Hooft Familie Webdienst</H2> <dtml-else> <H2>The Hooft Family Web</H2> </dtml-if> ....etc.... ------------------------------------- One advantage of this approach is that it keeps the different versions together (making updates to the information easy to keep consistent). One disadvantage of this approach is that it keeps the different versions together (making it difficult to appoint different people to maintaining the different languages), and another disadvantage is that it clutters up the dtml source. Suggestions for improvements always welcome. Regards, Rob Hooft -- ===== rob@hooft.net http://www.hooft.net/people/rob/ ===== ===== R&D, Nonius BV, Delft http://www.nonius.nl/ ===== ===== PGPid 0xFA19277D ========================== Use Linux! =========
participants (2)
-
Dieter Maurer -
rob@hooft.net