<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Vincent Fretin a &eacute;crit&nbsp;:
<blockquote
 cite="mid:85684d1c1002100014p175f8ff8uda1bcbe59c903a6a@mail.gmail.com"
 type="cite">
  <pre wrap="">On Tue, Feb 9, 2010 at 3:38 PM, Sylvain Viollon <a class="moz-txt-link-rfc2396E" href="mailto:sylvain@infrae.com">&lt;sylvain@infrae.com&gt;</a> wrote:
  </pre>
  <blockquote type="cite">
    <pre wrap="">On Tue, 9 Feb 2010 15:23:12 +0100
Souheil CHELFOUH <a class="moz-txt-link-rfc2396E" href="mailto:trollfot@gmail.com">&lt;trollfot@gmail.com&gt;</a> wrote:

&nbsp;Hello,

    </pre>
    <blockquote type="cite">
      <pre wrap="">I think that the request language is not taken by default so it's
always considered as english.
You can have a look here :
<a class="moz-txt-link-freetext" href="http://chameleon.repoze.org/docs/latest/i18n.html">http://chameleon.repoze.org/docs/latest/i18n.html</a> Have a look at the
i18n:target.


      </pre>
    </blockquote>
    <pre wrap="">&nbsp;Or you can set target_language in your namespace on your view:

&nbsp;def namespace(self):
&nbsp; &nbsp; &nbsp;return {'target_language': 'fr'}
    </pre>
  </blockquote>
  <pre wrap=""><!---->
Really? You have to do this yourself?
The question is how the classic pagetemplate works in this case? I'm
really interested to know that.

In this case, maybe you can make this dynamic with:
self.request.locale.getLocaleID()
u'fr_FR'

self.request.locale is already the result of an
IUserPreferredLanguages, I think the one registered in
zope/publisher/browser.py
The code which set request.locale is in
zope.publisher/http.py:HTTPRequest.setupLocale

Vincent
_______________________________________________
Grok-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Grok-dev@zope.org">Grok-dev@zope.org</a>
<a class="moz-txt-link-freetext" href="https://mail.zope.org/mailman/listinfo/grok-dev">https://mail.zope.org/mailman/listinfo/grok-dev</a>
  </pre>
</blockquote>
Thanks for your answers. I use the following base view for all my views
and it works perfectly:<br>
<br>
class BaseView(grok.View):<br>
&nbsp;&nbsp;&nbsp; """."""<br>
&nbsp;&nbsp;&nbsp; grok.baseclass()<br>
<br>
&nbsp;&nbsp;&nbsp; def namespace(self):<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return {'target_language': self.request.locale.getLocaleID()}<br>
<br>
getLocaleID() returns the same result as:<br>
<br>
&nbsp;&nbsp;&nbsp; from zope.publisher.browser import BrowserLanguages<br>
&nbsp;&nbsp;&nbsp; lang =
unicode(BrowserLanguages(self.request).getPreferredLanguages()[0])<br>
<br>
Sylvain<br>
<pre class="moz-signature" cols="72">-- 
Sylvain Boureliou, Ing&eacute;nieur Zope/Python/Plone
MAKINA CORPUS - <a class="moz-txt-link-abbreviated" href="http://www.makina-corpus.com">www.makina-corpus.com</a>
44 Boulevard des pas enchant&eacute;s FR-44230 Saint S&eacute;bastien Sur Loire
T : +33 (0) 2 51 79 80 80

Email : <a class="moz-txt-link-abbreviated" href="mailto:sylvain.boureliou@makina-corpus.com">sylvain.boureliou@makina-corpus.com</a>
</pre>
</body>
</html>