I have an app in two languages. Until now I was asking the users to change the language in their browser. I have now implemented setlang in the web interface, so that they can view in the language of their choice by choosing the language. I now want to do this in admin - a custom form should do it, but has anyone done this? Or is it going to come to admin? Or maybe it is there and I have not noticed it? -- regards Kenneth Gonsalves Senior Project Officer NRC-FOSS http://nrcfosshelpline.in/web/
> I have an app in two languages. Until now I was asking the users to change the > language in their browser. I have now implemented setlang in the web > interface, so that they can view in the language of their choice by choosing > the language. I now want to do this in admin - a custom form should do it, but > has anyone done this? Or is it going to come to admin? Or maybe it is there > and I have not noticed it?
And letting the users to change their language modifiying the main admin template and giving them a change language form?
I use the breadcrumbs block in the admin interface to add a link to a
view
using :
(in template)
<div id="breadcrumbs"
<p><span class="breadcrumbs">
<a class="discreet_link" href="{% url content.views.set_language
lang_code="fr" %}">Fr</a> |
<a class="discreet_link" href="{% url content.views.set_language
lang_code="nl" %}">Nl</a> |
<a class="discreet_link" href="{% url content.views.set_language
lang_code="en" %}">En</a> |
<a class="discreet_link" href="{% url content.views.set_language
lang_code="ja" %}"> >日本語</a>
</span></p>
(for each language, in every page, impractical if you have many, but
you can replace that by a special page of links if that's the case
(like google's language switch page) )
</div>
(in url.py)
(r'^lang/(?P<lang_code>[a-zA-Z]+)/$',set_language),
And then I just set the language cookie manually
(in views.py)
def set_language(request,**kwargs):
next = request.REQUEST.get('next', None)
if not next:
next = request.META.get('HTTP_REFERER', None)
if not next:
next = '/'
lang_code = kwargs.get("lang_code",None)
response=HttpResponseRedirect(next)
if lang_code and check_for_language(lang_code):
if hasattr(request, 'session'):
request.session['django_language'] = lang_code
else:
response.set_cookie(settings.LANGUAGE_COOKIE_NAME,
lang_code)
return response
On Nov 7, 9:49 am, Antoni Aloy <antoni.a...@gmail.com> wrote:
> > I have an app in two languages. Until now I was asking the users to change the
> > language in their browser. I have now implemented setlang in the web
> > interface, so that they can view in the language of their choice by choosing
> > the language. I now want to do this in admin - a custom form should do it, but
> > has anyone done this? Or is it going to come to admin? Or maybe it is there
> > and I have not noticed it?
> And letting the users to change their language modifiying the main
> admin template and giving them a change language form?
On Saturday 07 Nov 2009 3:19:54 pm Antoni Aloy wrote:
> > hi,
> > I have an app in two languages. Until now I was asking the users to > > change the language in their browser. I have now implemented setlang in > > the web interface, so that they can view in the language of their choice > > by choosing the language. I now want to do this in admin - a custom form > > should do it, but has anyone done this? Or is it going to come to admin? > > Or maybe it is there and I have not noticed it?
> And letting the users to change their language modifiying the main > admin template and giving them a change language form?
well I added the change language form to the main base.html form in admin (by overriding it), but the call to "/i18n/setlang/" is not working. Maybe a path problem. Any clues? -- regards Kenneth Gonsalves Senior Project Officer NRC-FOSS http://nrcfosshelpline.in/web/
On Sunday 08 Nov 2009 9:47:53 am Kenneth Gonsalves wrote:
> > And letting the users to change their language modifiying the main > > admin template and giving them a change language form?
> well I added the change language form to the main base.html form in admin > (by overriding it), but the call to "/i18n/setlang/" is not working. > Maybe a path problem. Any clues?
now it is working - neat ;-) -- regards Kenneth Gonsalves Senior Project Officer NRC-FOSS http://nrcfosshelpline.in/web/
On Sunday 08 Nov 2009 9:51:23 am Kenneth Gonsalves wrote:
> > well I added the change language form to the main base.html form in admin > > (by overriding it), but the call to "/i18n/setlang/" is not working. > > Maybe a path problem. Any clues?
> now it is working - neat ;-)
it was not a path problem, the browser needed to be refreshed to show the language change -- regards Kenneth Gonsalves Senior Project Officer NRC-FOSS http://nrcfosshelpline.in/web/