Changeset 3318
- Timestamp:
- 07/10/06 21:49:56 (2 years ago)
- Files:
-
- django/trunk/docs/i18n.txt (modified) (2 diffs)
- django/trunk/docs/settings.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/docs/i18n.txt
r3247 r3318 453 453 * Only languages listed in the `LANGUAGES setting`_ can be selected. If 454 454 you want to restrict the language selection to a subset of provided 455 languages (because your appli action doesn't provide all those languages),455 languages (because your application doesn't provide all those languages), 456 456 set ``LANGUAGES`` to a list of languages. For example:: 457 457 … … 466 466 467 467 .. _LANGUAGES setting: http://www.djangoproject.com/documentation/settings/#languages 468 469 * If you define a custom ``LANGUAGES`` setting, as explained in the 470 previous bullet, it's OK to mark the languages as translation strings 471 -- but use a "dummy" ``gettext()`` function, not the one in 472 ``django.utils.translation``. You should *never* import 473 ``django.utils.translation`` from within your settings file, because that 474 module in itself depends on the settings, and that would cause a circular 475 import. 476 477 The solution is to use a "dummy" ``gettext()`` function. Here's a sample 478 settings file:: 479 480 gettext = lambda s: s 481 482 LANGUAGES = ( 483 ('de', gettext('German')), 484 ('en', gettext('English')), 485 ) 486 487 With this arrangement, ``make-messages.py`` will still find and mark 488 these strings for translation, but the translation won't happen at 489 runtime -- so you'll have to remember to wrap the languages in the *real* 490 ``gettext()`` in any code that uses ``LANGUAGES`` at runtime. 491 468 492 * The ``LocaleMiddleware`` can only select languages for which there is a 469 493 Django-provided base translation. If you want to provide translations django/trunk/docs/settings.txt
r3297 r3318 502 502 to restrict language selection to a subset of the Django-provided languages. 503 503 504 If you define a custom ``LANGUAGES`` setting, it's OK to mark the languages as 505 translation strings (as in the default value displayed above) -- but use a 506 "dummy" ``gettext()`` function, not the one in ``django.utils.translation``. 507 You should *never* import ``django.utils.translation`` from within your 508 settings file, because that module in itself depends on the settings, and that 509 would cause a circular import. 510 511 The solution is to use a "dummy" ``gettext()`` function. Here's a sample 512 settings file:: 513 514 gettext = lambda s: s 515 516 LANGUAGES = ( 517 ('de', gettext('German')), 518 ('en', gettext('English')), 519 ) 520 521 With this arrangement, ``make-messages.py`` will still find and mark these 522 strings for translation, but the translation won't happen at runtime -- so 523 you'll have to remember to wrap the languages in the *real* ``gettext()`` in 524 any code that uses ``LANGUAGES`` at runtime. 525 504 526 MANAGERS 505 527 --------
