Skip to content
geomin edited this page Nov 13, 2010 · 4 revisions
  1. Get the source: git clone http://github.com/geomin/django-lingua.git
  2. Install polib (bitbucket.org/izi/polib/ )
  3. Add it to PYTHONPATH
  4. Modify settings.py and add 'lingua' to your INSTALLED_APPS:
    INSTALLED_APPS = (
        'lingua',
        ...
    )
  1. Modify your models and mark field to translate:
    from django.db import models
    from lingua import translation

    class Table(models.Model):
        class Translation(translation.Translation):
            name = models.CharField(max_length=32)
  1. Active the admin(optional)
    from lingua.admin import LinguaModelAdmin
    from django.contrib import admin
    from yourproject.yourapp.models import SomeModel    

    class SomeAdminClass(LinguaModelAdmin):
        #custom options
        pass
    
    admin.site.register( SomeModel, SomeAdminClass )
  1. Fill some data into the database to translate

  2. Run ./manage.py collectmessages It will fetch all data to translate and store them into the file 'db_translation.html'.

  3. Run django-admin.py makemessages -l

  4. Translate into your language. Use the admin interface to translate your models. As soon you save the model the translate is active.

  5. Run django-admin.py compilemessages

  6. In the view you can use like fieldname_, i.e. name_de or name_es. Use fieldname_00 to get the original value

  7. Make sure the the locale folder is writeable for polib

Clone this wiki locally