Ticket #5684: i18n.diff

File i18n.diff, 2.6 KB (added by Gabriel Farrell, 17 years ago)

i18n_LANGUAGES_ugettext

  • docs/i18n.txt

     
    555555    * Only languages listed in the `LANGUAGES setting`_ can be selected. If
    556556      you want to restrict the language selection to a subset of provided
    557557      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.
    559565
    560           LANGUAGES = (
    561             ('de', _('German')),
    562             ('en', _('English')),
    563           )
    564 
    565       This example restricts languages that are available for automatic
    566       selection to German and English (and any sublanguage, like de-ch or
    567       en-us).
    568 
    569       .. _LANGUAGES setting: ../settings/#languages
    570 
    571     * If you define a custom ``LANGUAGES`` setting, as explained in the
    572       previous bullet, it's OK to mark the languages as translation strings
    573       -- but use a "dummy" ``ugettext()`` function, not the one in
    574       ``django.utils.translation``. You should *never* import
    575       ``django.utils.translation`` from within your settings file, because that
    576       module in itself depends on the settings, and that would cause a circular
    577       import.
    578 
    579566      The solution is to use a "dummy" ``ugettext()`` function. Here's a sample
    580567      settings file::
    581568
     
    586573              ('en', ugettext('English')),
    587574          )
    588575
     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
    589580      With this arrangement, ``make-messages.py`` will still find and mark
    590581      these strings for translation, but the translation won't happen at
    591       runtime -- so you'll have to remember to wrap the languages in the *real*
     582      runtime -- you'll have to wrap the languages in the *real*
    592583      ``ugettext()`` in any code that uses ``LANGUAGES`` at runtime.
    593584
     585      .. _LANGUAGES setting: ../settings/#languages
     586
    594587    * The ``LocaleMiddleware`` can only select languages for which there is a
    595588      Django-provided base translation. If you want to provide translations
    596589      for your application that aren't already in the set of translations
Back to Top