django-modular-languages

Simple script to manage multiple language catalogs in a Django project
Download

django-modular-languages Ranking & Summary

Advertisement

  • Rating:
  • License:
  • GPL v3
  • Price:
  • FREE
  • Publisher Name:
  • Oscar Carballal Prego
  • Publisher web site:
  • http://github.com/cidadania/

django-modular-languages Tags


django-modular-languages Description

django-modular-languages is a Django app that automates the creation and maintenance of multiple language catalogs across a Django project. The current language maintenance tool included in django does not manage multiple catalogs sparsed through the django project tree, this script ends that. Using this script with transifex-client is a very good option.How to installTo install this script you must copy it inside your project root (in the same directory as settings.py) or you can make a "scripts" directory inside your project root and copy the script there.Configuring django to use the scriptDjango has (in my opinion) the bad habit of including all the applications in the same variable: INSTALLED_APPS, that is not a good thing, because it doesn't isolate the user applications.What you need to do is just that, isolate your applications from the django ones, making another variable, for example MYPROJECT_APPS and then unite them to the django ones in INSTALLED_APPS. In this example case, the project applications have been separated into three categories: DJANGO_APPS, THIRDPARTY_APPS (applications included in the project but not developed by the team) and MYPROJECT_APPS, including just the project application that we have developed.DJANGO_APPS = ( # This list is from the builtin applications in django. Watch out for # applications that need some specific order, like django-grappelli in # this case. It's a third part app, but due to the load order, we must # put it here. 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.staticfiles', 'django.contrib.sites', 'django.contrib.messages', 'grappelli.dashboard', 'grappelli', 'django.contrib.admin', 'django.contrib.comments',)THIRDPARTY_APPS = ( # This list is from the third party software included in the project or # system-wide dependencies. 'django_wysiwyg', 'myproject.apps.userprofile', 'myproject.apps.tagging', #'django_extensions',)MYPROJECT_MODULES = ( # Modules created for the project and installed by default. You can add # here your own modules. 'myproject.apps.accounts', 'myproject.apps.proposals', 'myproject.apps.news', 'myproject.apps.debate', 'myproject.apps.spaces', 'myproject.apps.staticpages', 'myproject.apps.cal',)INSTALLED_APPS = DJANGO_APPS + THIRDPARTY_APPS + MYPROJECT_MODULESAfter you have configured your applications variables, you must declare the languages you will use on the project with LANGUAGES. If you already have a multilingual django project it's quite probable that you already have this defined. If not, you will have to define a python dictionary with LANG_CODE:LANG_NAME. For example:LANGUAGES = ( ('es_ES', 'Espanol'), ('en_GB', 'English'), ('gl_ES', 'Galego'),)How to use the scriptThis script is run from the command line, in the project root or in the scripts directory. If you don't exceute it from there it will fail to locate the settings.py file. It has three basic commands:- make Creates (or updates) all the language catalogs in your project- compile Compiles after translation all the language catalogs- clean Removes all the language catalogs from the project. Asks for confirmation firstThere is also a "help" command which output is: ./generate_languages.py --helpusage: generate_languages.py {make,compile,clean} ...e-cidadania language catalog generator. This script manages all the .po and.mo files from templates, python code and javascript i18n (if used).positional arguments: {make,compile,clean} make Create all the language catalogs for translation, including JavaScript. compile Compile all the language catalogs for use. clean Delete all the language catalogs. After this you will have to rebuild the catalogs and translate them.optional arguments:-h, --help show this help message and exitFor example, to create or update your language catalogs, the command would be: python generate_languages.py makeWhich output should be (we're using e-cidadania project as example):>> Languages to generate: - Espanol - English - Galego>> Installed applications: - accounts - proposals - news - debate - spaces - staticpages - cal>> Generating language catalog: accountsprocessing language es_ESprocessing language en_GBprocessing language gl_ES>> Generating language catalog: proposalsprocessing language es_ESprocessing language en_GBprocessing language gl_ES(after ending the standard catalogs it starts with JavaScript ones)>> Generating JavaScript language catalog: accountsprocessing language es_ESprocessing language en_GBprocessing language gl_ES>> Generating JavaScript language catalog: proposalsprocessing language es_ESprocessing language en_GBprocessing language gl_ES(etc., etc.)Product's homepage


django-modular-languages Related Software