views:

53

answers:

3

Hi

I have and old django site (0.97-pre-SVN-7457) and I'm about to make some changes and get the site running on the current development code of django.

I have alot of content that needs to be intact. When I started the site, I made an ugly "hack" to get a dual lingual site, so the result is not pretty:

Here is my model:

class Entry(models.Model):
title_NO = models.CharField(max_length=500)
teaser_NO = models.TextField(blank=True, null=True,)
body_NO = models.TextField(blank=True, null=True,)
title_EN = models.CharField(max_length=500, blank=True, null=True)
teaser_EN = models.TextField(blank=True, null=True,)
body_EN = models.TextField(blank=True, null=True,)
...

In my templates I have written:

<div id="language_NO">
<h1>{{object.title_NO}}</h1>
.....
</div>
<div id="language_EN">
<h1>{{object.title_EN}}</h1>
 .....
</div>

And using a simple javascript to determine wich div to show (Printing the content twice in the template is very ugly, I know!)

So, now that I want to make some changes, what is the best way to go?

I have tried to read the documentation on the subject, but I cant find anything explaining what to do with the urls and templates.

The only current thing I have found is how to change the language correct

Your help is much appreciated!

A: 

There are various third-party projects that manage this sort of thing. Here's one review.

Daniel Roseman
+2  A: 

Google code has a library that provides support for multilingual content in Django models.

Jonas Gorauskas
I hoped someone would point me to a complete example. Still not getting how to set up my templates to use the Norwegian content when the norwegian language is selected, and vice versa for the english content, whith the setup I have in my models.pyDo I do something like this:{% if language_code.en %}{{object.title_EN}}{% else %}{{object.title_NO}}...?
Anthrax00
A: 

The answer is was looking for was this:

in my template:

{% load i18n %}{% get_current_language as LANGUAGE_CODE %}

{% ifequal LANGUAGE_CODE "en" %}                    
<h2>{{object.title_EN }}</h2>
{% else %}
<h2>{{object.title_NO }}</h2>
{% endifequal %}
Anthrax00