Changeset 7844 for django/trunk/docs/i18n.txt
- Timestamp:
- 07/06/08 01:39:44 (5 months ago)
- Files:
-
- django/trunk/docs/i18n.txt (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/docs/i18n.txt
r7842 r7844 123 123 (The caveat with using variables or computed values, as in the previous two 124 124 examples, is that Django's translation-string-detecting utility, 125 `` make-messages.py``, won't be able to find these strings. More on126 ``make -messages`` later.)125 ``django-admin.py makemessages``, won't be able to find these strings. More on 126 ``makemessages`` later.) 127 127 128 128 The strings you pass to ``_()`` or ``ugettext()`` can take placeholders, … … 394 394 language. Message files have a ``.po`` file extension. 395 395 396 Django comes with a tool, ``bin/make-messages.py``, that automates the creation 397 and upkeep of these files. 396 Django comes with a tool, ``django-admin.py makemessages``, that automates the 397 creation 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. 398 403 399 404 To create or update a message file, run this command:: 400 405 401 bin/make-messages.py-l de406 django-admin.py makemessages -l de 402 407 403 408 ...where ``de`` is the language code for the message file you want to create. … … 424 429 .. admonition:: No gettext? 425 430 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 file429 (``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. 431 436 432 437 The format of ``.po`` files is straightforward. Each ``.po`` file contains a … … 441 446 _("Welcome to my site.") 442 447 443 ...then `` make-messages.py`` will have created a ``.po`` file containing the444 following snippet -- a message::448 ...then ``django-admin.py makemessages`` will have created a ``.po`` file 449 containing the following snippet -- a message:: 445 450 446 451 #: path/to/python/module.py:23 … … 477 482 update all message files for **all** languages, run this:: 478 483 479 make-messages.py-a484 django-admin.py makemessages -a 480 485 481 486 Compiling message files … … 484 489 After you create your message file -- and each time you make changes to it -- 485 490 you'll need to compile it into a more efficient form, for use by ``gettext``. 486 Do this with the `` bin/compile-messages.py`` utility.491 Do this with the ``django-admin.py compilemessages`` utility. 487 492 488 493 This tool runs over all available ``.po`` files and creates ``.mo`` files, 489 494 which are binary files optimized for use by ``gettext``. In the same directory 490 from which you ran `` make-messages.py``, run ``compile-messages.py`` like491 this::492 493 bin/compile-messages.py495 from which you ran ``django-admin.py makemessages``, run 496 ``django-admin.py compilemessages`` like this:: 497 498 django-admin.py compilemessages 494 499 495 500 That'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. 496 507 497 508 .. admonition:: A note to translators … … 599 610 ) 600 611 601 With this arrangement, `` make-messages.py`` will still find and mark602 these strings for translation, but the translation won't happen at603 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* 604 615 ``ugettext()`` in any code that uses ``LANGUAGES`` at runtime. 605 616 … … 678 689 * ``$PYTHONPATH/django/conf/locale/<language>/LC_MESSAGES/django.(po|mo)`` 679 690 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. 691 To create message files, you use the same ``django-admin.py makemessages`` 692 tool 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 694 tree) or the ``locale/`` (in case of app messages or project messages) 695 directory are located. And you use the same ``django-admin.py compilemessages`` 696 to produce the binary ``django.mo`` files that are used by ``gettext``. 697 698 You can also run ``django-admin.py compilemessages --settings=path.to.settings`` 699 to make the compiler process all the directories in your ``LOCALE_PATHS`` 700 setting. 689 701 690 702 Application message files are a bit complicated to discover -- they need the … … 696 708 be used in other projects, you might want to use app-specific translations. 697 709 But using app-specific translations and project translations could produce 698 weird problems with ``make -messages``: ``make-messages`` will traverse all710 weird problems with ``makemessages``: ``makemessages`` will traverse all 699 711 directories below the current path and so might put message IDs into the 700 712 project message file that are already in application message files. … … 702 714 The easiest way out is to store applications that are not part of the project 703 715 (and so carry their own translations) outside the project tree. That way, 704 `` make-messages`` on the project level will only translate strings that are705 connected to your explicit project and not strings that are distributed 706 independently.716 ``django-admin.py makemessages`` on the project level will only translate 717 strings that are connected to your explicit project and not strings that are 718 distributed independently. 707 719 708 720 The ``set_language`` redirect view … … 859 871 860 872 You create and update the translation catalogs the same way as the other 861 Django translation catalogs -- with the make-messages.py tool. The only862 difference is you need to provide a ``-d djangojs`` parameter, like this::863 864 make-messages.py-d djangojs -l de873 Django translation catalogs -- with the django-admin.py makemessages tool. The 874 only difference is you need to provide a ``-d djangojs`` parameter, like this:: 875 876 django-admin.py makemessages -d djangojs -l de 865 877 866 878 This would create or update the translation catalog for JavaScript for German. 867 After updating translation catalogs, just run `` compile-messages.py`` the same868 way as you do with normal Django translation catalogs.879 After updating translation catalogs, just run ``django-admin.py compilemessages`` 880 the same way as you do with normal Django translation catalogs. 869 881 870 882 Specialties of Django translation
