Ticket #5684: i18n.diff
File i18n.diff, 2.6 KB (added by , 17 years ago) |
---|
-
docs/i18n.txt
555 555 * Only languages listed in the `LANGUAGES setting`_ can be selected. If 556 556 you want to restrict the language selection to a subset of provided 557 557 languages (because your application doesn't provide all those languages), 558 set ``LANGUAGES`` to a list of languages. For example:: 558 set ``LANGUAGES`` to a list of languages. 559 560 It's OK to mark the languages as translation strings, but use a "dummy" 561 ``ugettext()`` function, not the one in ``django.utils.translation``. 562 You should *never* import ``django.utils.translation`` from within your 563 settings file, because that module in itself depends on the settings, 564 and that would cause a circular import. 559 565 560 LANGUAGES = (561 ('de', _('German')),562 ('en', _('English')),563 )564 565 This example restricts languages that are available for automatic566 selection to German and English (and any sublanguage, like de-ch or567 en-us).568 569 .. _LANGUAGES setting: ../settings/#languages570 571 * If you define a custom ``LANGUAGES`` setting, as explained in the572 previous bullet, it's OK to mark the languages as translation strings573 -- but use a "dummy" ``ugettext()`` function, not the one in574 ``django.utils.translation``. You should *never* import575 ``django.utils.translation`` from within your settings file, because that576 module in itself depends on the settings, and that would cause a circular577 import.578 579 566 The solution is to use a "dummy" ``ugettext()`` function. Here's a sample 580 567 settings file:: 581 568 … … 586 573 ('en', ugettext('English')), 587 574 ) 588 575 576 This example restricts languages that are available for automatic 577 selection to German and English (and any sublanguage, like de-ch or 578 en-us). 579 589 580 With this arrangement, ``make-messages.py`` will still find and mark 590 581 these strings for translation, but the translation won't happen at 591 runtime -- so you'll have to rememberto wrap the languages in the *real*582 runtime -- you'll have to wrap the languages in the *real* 592 583 ``ugettext()`` in any code that uses ``LANGUAGES`` at runtime. 593 584 585 .. _LANGUAGES setting: ../settings/#languages 586 594 587 * The ``LocaleMiddleware`` can only select languages for which there is a 595 588 Django-provided base translation. If you want to provide translations 596 589 for your application that aren't already in the set of translations