Re: i18n and images

Guillem Comes <[email protected]> Thu, 24 May 2007 21:45:02 +0200 (CEST)
Newsgroups gmane.comp.web.zope.page-templates
Message-ID <[email protected]>
On 5/24/07, Josef Meile <[email protected]> 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.
>=20
> Anyway, if I'm not wrong, it is possible to get the
current
> language by doing:
>=20
> lang =3D getattr(REQUEST,'language')
>=20
> You may also try
>=20
> lang =3D getattr(REQUEST,'HTTP_ACCEPT_LANGUAGE')
>=20
> If not, print the REQUEST object in a template and
see the
> variables on it.
>=20
> Another way I used it an Python Product was:
>=20
> def getLanguage(context,domain=3DNone):
>    """Gets the current language of the user
browser"""
>=20
>    #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 =3D
context.Control_Panel.TranslationService
>    currentLanguage =3D
TranslationService.negotiate_language(request,domain)
>=20
>    if currentLanguage=3D=3DNone:
>      #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'
>=20
>    return return currentLanguage[0:2]
>=20
> Best regards
> Josef
>=20

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


	=09
______________________________________________=20
LLama Gratis a cualquier PC del Mundo.=20
Llamadas a fijos y m=F3viles desde 1 c=E9ntimo por minuto.=20
http://es.voice.yahoo.com