Created
September 3, 2015 12:44
-
-
Save Varnan/7c2eb085a6b6ee5b8c69 to your computer and use it in GitHub Desktop.
Model Translation - Multi language support for your Django project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
======================= Model Translation =============================================== | |
Its also very simpleModel Translation, if you want to translate data inside the db, then it will add new field for the languages that you have set in settings.py, | |
#### Just follow this: | |
http://django-modeltranslation.readthedocs.org/en/latest/ | |
######### Model stranslation Work flow #################### | |
Step: 1 | |
Set languages for the site in settings.py file. | |
Step:2 | |
Install modeltranslation app, using pip install django-modeltranslation, | |
Step:3 | |
Add modeltranslation to INSTALLED_APPS before contrib.admin, | |
INSTALLED_APPS = ( | |
'modeltranslation', | |
'django.contrib.admin', # optional | |
) | |
Step:4 | |
Set URL conf as i18n_patterns, import from django.conf.urls.i18n import i18n_patterns, in urls.py file | |
Example: | |
urlpatterns = i18n_patterns('', | |
url(r'^ckeditor/', include(admin.site.urls)), | |
) | |
Step:5 | |
create the translation file, like translation.py inside the apps model that you want to translate. | |
Just follow this link: | |
http://django-modeltranslation.readthedocs.org/en/latest/registration.html?highlight=translation.py | |
At last migrate just like this, | |
1 . python manage.py makemigrations | |
2. python manage.py migrate | |
Thats it.. | |
Remaining part will managed by sort of middlewares. | |
For the complete reference check the link: | |
http://django-modeltranslation.readthedocs.org/en/latest/index.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment