-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathHOWTO.txt
executable file
·51 lines (33 loc) · 1.33 KB
/
HOWTO.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
1. Checkout the code
git http://github.com/geomin/django-lingua.git
2. Add the path to PYTHONPATH
3. Add 'lingua' to your INSTALLED_APPS:
INSTALLED_APPS = (
'lingua',
...
)
4. Create or modify your models:
from django.db import models
from lingua import translation
class Table(models.Model):
class Translation(translation.Translation):
name = models.CharField(max_length=32)
5. 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 )
6. Fill some data into the database to translate
7. Run ./manage.py collectmessages
It will fetch all data to translate and store them into the file 'db_translation.html'.
8. Run django-admin.py makemessages -l <lang>
9. Translate into your language. Use the admin interface to translate your models.
As soon you save the model the translate is active.
10. Run django-admin.py compilemessages
11. In the view you can use like <field_name>_<lang>, i.e. name_de or name_es.
Use <field_name>_00 to get the original value
Done!
Check the django i18n documentation to get more information.