Language code prefix in url

34 views
Skip to first unread message

Tirta K. Untario

unread,
Dec 21, 2008, 10:52:00 PM12/21/08
to django...@googlegroups.com
Hi all, I'm new to Django, and trying to port my old site to Django for practice purpose.

Different from Django multilingual implementation by using cookie, I want to add lang code to every url, i.e:

/en/my_app/something_here/1/2/3/4/
/de/my_app/something_here/1/2/3/4/
/fr/my_app/something_here/1/2/3/4/

The main reason I do this if for Google to index more pages from my site. I don't want Google to index just the English version (default language), but I think that what will happen if I use cookies.

I hope this approcae can be integrated with pre-existing Django apps without much hassles. I currently in fond of flatpages :)

Do anyone have any idea on how to do this? TIA.

--Tirta

Wayper, Paul

unread,
Dec 21, 2008, 11:24:03 PM12/21/08
to django...@googlegroups.com
> From: Tirta K. Untario
> Subject: Language code prefix in url
>
> /en/my_app/something_here/1/2/3/4/
> /de/my_app/something_here/1/2/3/4/
> /fr/my_app/something_here/1/2/3/4/

My suggestion would be to look at e.g. Apache's URL rewriting rules.
Take those URLs and produce
/my_app/something_here/1/2/3/4/?lang={en,de,fr}, then pick that up in
your environment. Maybe make some middleware that picks that out of the
GET parameters automatically and gives you it in some useful way. I'm
guessing what you want to use it for is to select which directory you
pick your templates from.

Just a thought,

--
Paul Wayper
SYSTEMS ENGINEER
TransACT

Telephone: 02 6229 8026
Mobile: 0422 392 081

PO Box 1006, Civic Square ACT 2608

www.transact.com.au

Malcolm Tredinnick

unread,
Dec 21, 2008, 11:26:42 PM12/21/08
to django...@googlegroups.com

Joost Cassee's localeurl project
(http://code.google.com/p/django-localeurl/ ) is one approach to this
problem that seems fairly well thought out.

Regards,
Malcolm


Tirta K. Untario

unread,
Dec 22, 2008, 2:56:57 AM12/22/08
to django...@googlegroups.com
Wow, this is exactly what I'm looking for. I'm gonna try this app soon. Thanks!

--Tirta
-----Original Message-----
From: Malcolm Tredinnick <mal...@pointy-stick.com>

Date: Mon, 22 Dec 2008 15:26:42
To: <django...@googlegroups.com>
Subject: Re: Language code prefix in url
Reply all
Reply to author
Forward
0 new messages