forked from geomin/django-lingua
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HOWTO.txt
executable file
·55 lines (36 loc) · 1.57 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
52
53
54
55
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(translation.TranslationModel):
name = models.CharField(max_length=32)
_translation_fields = ('name',)
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 )
You can set `LINGUA_DEFAULT` to a specified language in you settings (default to 'en').
In the admin, it will display only your msgid and languages msgstr except for 'en' language
which is in most case the msgid language.
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 'extra_translations.py' for each app.
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.