summaryrefslogtreecommitdiff
path: root/docs/narr/i18n.rst
diff options
context:
space:
mode:
authorChris McDonough <chrism@agendaless.com>2010-04-25 19:29:37 +0000
committerChris McDonough <chrism@agendaless.com>2010-04-25 19:29:37 +0000
commit30b89889183acb9243f13cc141fae08a22b2d317 (patch)
tree58893cf2f64302456df4340bec5dec5163c9c7f2 /docs/narr/i18n.rst
parent0e498ca5ec62725daecd75c4ac747cfc380d029e (diff)
downloadpyramid-30b89889183acb9243f13cc141fae08a22b2d317.tar.gz
pyramid-30b89889183acb9243f13cc141fae08a22b2d317.tar.bz2
pyramid-30b89889183acb9243f13cc141fae08a22b2d317.zip
Normalize ZCML vs. imperative as per other chapter formatting.
Diffstat (limited to 'docs/narr/i18n.rst')
-rw-r--r--docs/narr/i18n.rst153
1 files changed, 78 insertions, 75 deletions
diff --git a/docs/narr/i18n.rst b/docs/narr/i18n.rst
index fbf623cfb..eb6f875cf 100644
--- a/docs/narr/i18n.rst
+++ b/docs/narr/i18n.rst
@@ -696,110 +696,112 @@ can provide your own locale negotiator function as required.
Adding a Translation Directory
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-You may add a :term:`translation directory` to your application's
-configuration either imperatively or via ZCML. Adding a translation
-directory registers all of its constituent :term:`message catalog`
-files (all of the ``.mo`` files found within all ``LC_MESSAGES``
-directories within each locale directory in the translation directory)
-within your :mod:`repoze.bfg` application to be available to use for
-translation services.
-
-Imperative
-++++++++++
-
-You can add a translation directory imperatively by using the
-:meth:`repoze.bfg.configuration.Configurator.add_translation_dirs`
-during application startup.
+Adding a :term:`translation directory` registers all of its
+constituent :term:`message catalog` files (all of the ``.mo`` files
+found within all ``LC_MESSAGES`` directories within each locale
+directory in the translation directory) within your :mod:`repoze.bfg`
+application to be available to use for translation services.
-For example:
+You may add a translation directory to your application's
+configuration using either imperative configuration or ZCML.
-.. code-block:: python
- :linenos:
+.. topic:: Using Imperative Configuration
- from repoze.bfg.configuration import Configurator
- from repoze.bfg.i18n import default_locale_negotiator
- config = Configurator(locale_negotiator=default_locale_negotiator)
- config.begin()
- config.add_translation_dirs('my.application:locale/',
- 'another.application:locale/')
- config.end()
-
-A message catalog in a translation directory added via
-:meth:`repoze.bfg.configuration.Configurator.add_translation_dirs`
-will be merged into translations from an message catalog added earlier
-if both translation directories contain translations for the same
-locale and :term:`translation domain`.
+ You can add a translation directory imperatively by using the
+ :meth:`repoze.bfg.configuration.Configurator.add_translation_dirs`
+ during application startup.
-ZCML
-++++
+ For example:
-You can add a translation directory via ZCML by using the
-:ref:`translationdir_directive` ZCML directive:
+ .. code-block:: python
+ :linenos:
-.. code-block:: xml
- :linenos:
+ from repoze.bfg.configuration import Configurator
+ from repoze.bfg.i18n import default_locale_negotiator
+ config = Configurator(
+ locale_negotiator=default_locale_negotiator)
+ config.begin()
+ config.add_translation_dirs('my.application:locale/',
+ 'another.application:locale/')
+ config.end()
+
+ A message catalog in a translation directory added via
+ :meth:`repoze.bfg.configuration.Configurator.add_translation_dirs`
+ will be merged into translations from an message catalog added earlier
+ if both translation directories contain translations for the same
+ locale and :term:`translation domain`.
+
+.. topic:: Using ZCML
+
+ You can add a translation directory via ZCML by using the
+ :ref:`translationdir_directive` ZCML directive:
+
+ .. code-block:: xml
+ :linenos:
- <translationdir dir="my.application:locale/"/>
+ <translationdir dir="my.application:locale/"/>
-A message catalog in a translation directory added via
-:ref:`translationdir_directive` will be merged into translations from
-an message catalog added earlier if both translation directories
-contain translations for the same locale and :term:`translation
-domain`.
+ A message catalog in a translation directory added via
+ :ref:`translationdir_directive` will be merged into translations from
+ an message catalog added earlier if both translation directories
+ contain translations for the same locale and :term:`translation
+ domain`.
.. _adding_a_locale_negotiator:
Adding a Locale Negotiator
~~~~~~~~~~~~~~~~~~~~~~~~~~
-You may add a :term:`locale negotiator` either imperatively or via
-ZCML. A locale negotiator informs the operation of a
+A :term:`locale negotiator` informs the operation of a
:term:`localizer` by telling it what :term:`locale name` is related to
a particular request. See :ref:`creating_a_locale_negotiator`.
-Imperative
-++++++++++
+You may add a locale directory to your application's
+configuration using either imperative configuration or ZCML.
-Pass an object which can act as the negotiator as the
-``locale_negotiator`` argument of the
-:class:`repoze.bfg.configuration.Configurator` instance during
-application startup.
+.. topic:: Using Imperative Configuration
-For example:
+ Pass an object which can act as the negotiator as the
+ ``locale_negotiator`` argument of the
+ :class:`repoze.bfg.configuration.Configurator` instance during
+ application startup.
-.. code-block:: python
- :linenos:
+ For example:
- from repoze.bfg.configuration import Configurator
- from repoze.bfg.i18n import default_locale_negotiator
- config = Configurator(locale_negotiator=default_locale_negotiator)
+ .. code-block:: python
+ :linenos:
-Alternately, use the
-:meth:`repoze.bfg.configuration.Configurator.set_locale_negotiator`
-method.
+ from repoze.bfg.configuration import Configurator
+ from repoze.bfg.i18n import default_locale_negotiator
+ config = Configurator(
+ locale_negotiator=default_locale_negotiator)
-For example:
+ Alternately, use the
+ :meth:`repoze.bfg.configuration.Configurator.set_locale_negotiator`
+ method.
-.. code-block:: python
- :linenos:
+ For example:
- from repoze.bfg.configuration import Configurator
- from repoze.bfg.i18n import default_locale_negotiator
- config = Configurator()
- config.begin()
- config.set_locale_negotiator(default_locale_negotiator)
- config.end()
+ .. code-block:: python
+ :linenos:
-ZCML
-++++
+ from repoze.bfg.configuration import Configurator
+ from repoze.bfg.i18n import default_locale_negotiator
+ config = Configurator()
+ config.begin()
+ config.set_locale_negotiator(default_locale_negotiator)
+ config.end()
-You can add a translation directory via ZCML by using the
-:ref:`localenegotiator_directive` ZCML directive:
+.. topic:: Using ZCML
-.. code-block:: xml
- :linenos:
+ You can add a translation directory via ZCML by using the
+ :ref:`localenegotiator_directive` ZCML directive:
- <localenegotiator negotiator="repoze.bfg.i18n.default_locale_negotiator"/>
+ .. code-block:: xml
+ :linenos:
+
+ <localenegotiator
+ negotiator="repoze.bfg.i18n.default_locale_negotiator"/>
.. _creating_a_locale_negotiator:
@@ -824,3 +826,4 @@ Locale negotiation can be complex. Your application may require a
policy-laden locale negotiator policy, so you can write your own and
supply it to an application configuration as per
:ref:`adding_a_locale_negotiator`.
+