-
Notifications
You must be signed in to change notification settings - Fork 5
Install Lingua
geomin edited this page Nov 13, 2010
·
4 revisions
- Get the source: git clone http://github.com/geomin/django-lingua.git
- Install polib (bitbucket.org/izi/polib/ )
- Add it to PYTHONPATH
- Modify settings.py and add 'lingua' to your INSTALLED_APPS:
INSTALLED_APPS = (
'lingua',
...
)
- 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)
- 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 )
-
Fill some data into the database to translate
-
Run ./manage.py collectmessages It will fetch all data to translate and store them into the file 'db_translation.html'.
-
Run django-admin.py makemessages -l
-
Translate into your language. Use the admin interface to translate your models. As soon you save the model the translate is active.
-
Run django-admin.py compilemessages
-
In the view you can use like fieldname_, i.e. name_de or name_es. Use fieldname_00 to get the original value
-
Make sure the the locale folder is writeable for polib