Django

Code

Show
Ignore:
Timestamp:
07/06/08 01:39:44 (5 months ago)
Author:
mtredinnick
Message:

Fixed #5522 -- Moved make-messages, compile-messages and daily-cleanup into django-admin.py.

They are now called "makemessages", "compilemessages" and "cleanup". This is
backwards incompatible for make-messages.py and compile-messages.py, although
the old executables still exist for now and print an error pointing the caller
to the right command to call.

This reduces the number of binaries and man pages Django needs to install.

Patch from Janis Leidel.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/docs/i18n.txt

    r7842 r7844  
    123123(The caveat with using variables or computed values, as in the previous two 
    124124examples, is that Django's translation-string-detecting utility, 
    125 ``make-messages.py``, won't be able to find these strings. More on 
    126 ``make-messages`` later.) 
     125``django-admin.py makemessages``, won't be able to find these strings. More on 
     126``makemessages`` later.) 
    127127 
    128128The strings you pass to ``_()`` or ``ugettext()`` can take placeholders, 
     
    394394language. Message files have a ``.po`` file extension. 
    395395 
    396 Django comes with a tool, ``bin/make-messages.py``, that automates the creation 
    397 and upkeep of these files. 
     396Django comes with a tool, ``django-admin.py makemessages``, that automates the 
     397creation and upkeep of these files.  
     398 
     399.. admonition:: A note to Django veterans 
     400 
     401    The old tool ``bin/make-messages.py`` has been moved to the command 
     402    ``django-admin.py makemessages`` to provide consistency throughout Django. 
    398403 
    399404To create or update a message file, run this command:: 
    400405 
    401     bin/make-messages.py -l de 
     406    django-admin.py makemessages -l de 
    402407 
    403408...where ``de`` is the language code for the message file you want to create. 
     
    424429.. admonition:: No gettext? 
    425430 
    426     If you don't have the ``gettext`` utilities installed, ``make-messages.py`` 
    427     will create empty files. If that's the case, either install the ``gettext`` 
    428     utilities or just copy the English message file 
    429     (``conf/locale/en/LC_MESSAGES/django.po``) and use it as a starting point; 
    430     it's just an empty translation file. 
     431    If you don't have the ``gettext`` utilities installed, 
     432    ``django-admin.py makemessages`` will create empty files. If that's the 
     433    case, either install the ``gettext`` utilities or just copy the English 
     434    message file (``conf/locale/en/LC_MESSAGES/django.po``) and use it as a 
     435    starting point; it's just an empty translation file. 
    431436 
    432437The format of ``.po`` files is straightforward. Each ``.po`` file contains a 
     
    441446    _("Welcome to my site.") 
    442447 
    443 ...then ``make-messages.py`` will have created a ``.po`` file containing th
    444 following snippet -- a message:: 
     448...then ``django-admin.py makemessages`` will have created a ``.po`` fil
     449containing the following snippet -- a message:: 
    445450 
    446451    #: path/to/python/module.py:23 
     
    477482update all message files for **all** languages, run this:: 
    478483 
    479     make-messages.py -a 
     484    django-admin.py makemessages -a 
    480485 
    481486Compiling message files 
     
    484489After you create your message file -- and each time you make changes to it -- 
    485490you'll need to compile it into a more efficient form, for use by ``gettext``. 
    486 Do this with the ``bin/compile-messages.py`` utility. 
     491Do this with the ``django-admin.py compilemessages`` utility. 
    487492 
    488493This tool runs over all available ``.po`` files and creates ``.mo`` files, 
    489494which are binary files optimized for use by ``gettext``. In the same directory 
    490 from which you ran ``make-messages.py``, run ``compile-messages.py`` like 
    491 this:: 
    492  
    493    bin/compile-messages.py 
     495from which you ran ``django-admin.py makemessages``, run 
     496``django-admin.py compilemessages`` like this:: 
     497 
     498   django-admin.py compilemessages 
    494499 
    495500That's it. Your translations are ready for use. 
     501 
     502.. admonition:: A note to Django veterans 
     503 
     504    The old tool ``bin/compile-messages.py`` has been moved to the command 
     505    ``django-admin.py compilemessages`` to provide consistency throughout 
     506    Django. 
    496507 
    497508.. admonition:: A note to translators 
     
    599610          ) 
    600611 
    601       With this arrangement, ``make-messages.py`` will still find and mark 
    602       these strings for translation, but the translation won't happen at 
    603       runtime -- so you'll have to remember to wrap the languages in the *real* 
     612      With this arrangement, ``django-admin.py makemessages`` will still find 
     613      and mark these strings for translation, but the translation won't happen 
     614      at runtime -- so you'll have to remember to wrap the languages in the *real* 
    604615      ``ugettext()`` in any code that uses ``LANGUAGES`` at runtime. 
    605616 
     
    678689    * ``$PYTHONPATH/django/conf/locale/<language>/LC_MESSAGES/django.(po|mo)`` 
    679690 
    680 To create message files, you use the same ``make-messages.py`` tool as with the 
    681 Django message files. You only need to be in the right place -- in the directory 
    682 where either the ``conf/locale`` (in case of the source tree) or the ``locale/`` 
    683 (in case of app messages or project messages) directory are located. And you 
    684 use the same ``compile-messages.py`` to produce the binary ``django.mo`` files 
    685 that are used by ``gettext``. 
    686  
    687 You can also run ``compile-message.py --settings=path.to.settings`` to make 
    688 the compiler process all the directories in your ``LOCALE_PATHS`` setting. 
     691To create message files, you use the same ``django-admin.py makemessages`` 
     692tool as with the Django message files. You only need to be in the right place 
     693-- in the directory where either the ``conf/locale`` (in case of the source 
     694tree) or the ``locale/`` (in case of app messages or project messages) 
     695directory are located. And you use the same ``django-admin.py compilemessages`` 
     696to produce the binary ``django.mo`` files that are used by ``gettext``. 
     697 
     698You can also run ``django-admin.py compilemessages --settings=path.to.settings`` 
     699to make the compiler process all the directories in your ``LOCALE_PATHS`` 
     700setting. 
    689701 
    690702Application message files are a bit complicated to discover -- they need the 
     
    696708be used in other projects, you might want to use app-specific translations. 
    697709But using app-specific translations and project translations could produce 
    698 weird problems with ``make-messages``: ``make-messages`` will traverse all 
     710weird problems with ``makemessages``: ``makemessages`` will traverse all 
    699711directories below the current path and so might put message IDs into the 
    700712project message file that are already in application message files. 
     
    702714The easiest way out is to store applications that are not part of the project 
    703715(and so carry their own translations) outside the project tree. That way, 
    704 ``make-messages`` on the project level will only translate strings that ar
    705 connected to your explicit project and not strings that are distributed 
    706 independently. 
     716``django-admin.py makemessages`` on the project level will only translat
     717strings that are connected to your explicit project and not strings that are 
     718distributed independently. 
    707719 
    708720The ``set_language`` redirect view 
     
    859871 
    860872You create and update the translation catalogs the same way as the other 
    861 Django translation catalogs -- with the make-messages.py tool. The only 
    862 difference is you need to provide a ``-d djangojs`` parameter, like this:: 
    863  
    864     make-messages.py -d djangojs -l de 
     873Django translation catalogs -- with the django-admin.py makemessages tool. The 
     874only difference is you need to provide a ``-d djangojs`` parameter, like this:: 
     875 
     876    django-admin.py makemessages -d djangojs -l de 
    865877 
    866878This would create or update the translation catalog for JavaScript for German. 
    867 After updating translation catalogs, just run ``compile-messages.py`` the same 
    868 way as you do with normal Django translation catalogs. 
     879After updating translation catalogs, just run ``django-admin.py compilemessages`` 
     880the same way as you do with normal Django translation catalogs. 
    869881 
    870882Specialties of Django translation