title: i18n Django Internationalization and database objects
body: <p>I'm working in a bilingual project (es/en); for this project I've chosen to use django's i18n internationalization system  (and I'm starting to regret it...)</p>
  
  <p>Today's problem is the following:<br>
  for some models, my database stores information like <code>description</code> and <code>es_description</code>, or <code>english_common_name</code> and <code>spanish_common_name</code> <em>(these are <strong>attributes</strong> of my objects, and are used in many circumstances, not only for page-translation issues)</em>.
  <br />
  <br></p>
  
  <p>A sample model can be defined like:</p>
  
  <pre><code>def MyModel(models.Model):
      name = ...
      type = ...
      authors = ...
      contributors = ...
      ...
      ...
      description = models.TextField(max_length = 800, blank=True)
      es_description = models.TextField(max_length = 800, blank=True)
      ...
      english_common_name = models.CharField('name', max_length=80, unique=True)
      spanish_common_name = models.CharField('nombre', max_length=80, unique=True)
      ...
  </code></pre>
  
  <p><br><br><br>
  Let's say I want to retrieve this information in my template, according to <code>lang</code>, the language selected by the user.</p>
  
  <p>For example, in some place of my template I could have something like </p>
  
  <pre><code>&lt;h1&gt;{{name}}&lt;/h1&gt;
  &lt;h3&gt;{{english_common_name}}&lt;/h3&gt;
  &lt;p&gt;{{description}}&lt;/p&gt;
  &lt;p&gt;{% trans "Contributors" %}: {{contributors}}&lt;/p&gt;
  </code></pre>
  
  <p>How can I call <code>{{spanish_common_name}}</code> instead of <code>{{english_common_name}}</code> or <code>{{es_description}}</code> instead of <code>{{description}}</code> if the page language is set to <code>'es'</code>?</p>
  
  <p><br /></p>
  
  <p>I absolutely refuse to do something like </p>
  
  <pre><code>&lt;p&gt;{% ifequal lang 'es' %}{{descrpition}}{% else %}{{es_description}}{% endifequal %}&lt;/p&gt;
  </code></pre>
  
  <p><br /></p>
  
  <p>And if I try to manage this in views...  I don't want to define a <code>get_translated_content</code> function like this</p>
  
  <pre><code>def get_translated_content(en_content,es_content,lang):
      if lang is 'es':
          return es_content
      else:
          return en_content
  
  ...
  # MyView
  ...
      return render_to_response(...,
                                {'object': my_object,
                                 'object_common_name': get_translated_content(english_common_name, spanish_common_name, lang),
                                 'object_description': get_translated_content(description, es_description, lang), 
                                  ... ,})
  </code></pre>
  
  <p>This could work (still being an horrible solution) in simple situations, but in more complex cases I would be forced to return dictionaries which are <em>localized copies of the original <code>MyModel</code> object</em> (and if in a view I have to use lots of different instances of the same model, I would be forced to generate a biiiig list of these dictionaries).</p>
  
  <p><br /><br />
  Please, tell me that there is a good, logic way to access db object-fields according to the page's language, please!</p>
  
  <p><br /><br />
  <strong>Edit:</strong> after reading the answers received so far, I think I should add to my question a "<em>leaving the database structure (almost) unchanged</em>" clause.</p>