[ZPT] Re: i18n and images
Guillem Comes
guillemc2001 at yahoo.es
Thu May 24 15:45:02 EDT 2007
On 5/24/07, Josef Meile <jmeile at hotmail.com> wrote:
> Sometime ago I did something similar with PTS, but
since
> zope 2.8.x you can use five, which has an own i18n
module,
> I rewrote my code.
>
> Anyway, if I'm not wrong, it is possible to get the
current
> language by doing:
>
> lang = getattr(REQUEST,'language')
>
> You may also try
>
> lang = getattr(REQUEST,'HTTP_ACCEPT_LANGUAGE')
>
> If not, print the REQUEST object in a template and
see the
> variables on it.
>
> Another way I used it an Python Product was:
>
> def getLanguage(context,domain=None):
> """Gets the current language of the user
browser"""
>
> #I known in the PTS API there is a better way to
get this, but
> #I'm not using it anymore, so I don't know where
it is. You
> #may trying by looking at the PTS source
> TranslationService =
context.Control_Panel.TranslationService
> currentLanguage =
TranslationService.negotiate_language(request,domain)
>
> if currentLanguage==None:
> #PlacelessTranslationService returns None
> #when using wget or urllib, so, I forced
> #english to be the default. Note: this was in
my old PTS,
> #I don't know if this is still the case
> return 'en'
>
> return return currentLanguage[0:2]
>
> Best regards
> Josef
>
Thanks a lot, Josef. The getLanguage function seems a
good solution indeed. I didn't manage to get it
working yet (newbie here), but will keep trying...
Guillem
______________________________________________
LLama Gratis a cualquier PC del Mundo.
Llamadas a fijos y móviles desde 1 céntimo por minuto.
http://es.voice.yahoo.com
More information about the ZPT
mailing list