summaryrefslogtreecommitdiff
path: root/docs/narr/i18n.rst
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2010-11-04 04:09:57 -0400
committerChris McDonough <chrism@plope.com>2010-11-04 04:09:57 -0400
commitf8ed006738963a555f691b2dfdeae19aa5ef6b0f (patch)
tree3ec1f3d9d277c8b3fd2496dffd67f7db9e2cf95f /docs/narr/i18n.rst
parent39f8a04ca89dfb43c79bf3c4c31400061a5cf1e0 (diff)
downloadpyramid-f8ed006738963a555f691b2dfdeae19aa5ef6b0f.tar.gz
pyramid-f8ed006738963a555f691b2dfdeae19aa5ef6b0f.tar.bz2
pyramid-f8ed006738963a555f691b2dfdeae19aa5ef6b0f.zip
move i18n ZCML topics to declarative chapter
Diffstat (limited to 'docs/narr/i18n.rst')
-rw-r--r--docs/narr/i18n.rst116
1 files changed, 42 insertions, 74 deletions
diff --git a/docs/narr/i18n.rst b/docs/narr/i18n.rst
index aaa1962e8..a7b952019 100644
--- a/docs/narr/i18n.rst
+++ b/docs/narr/i18n.rst
@@ -845,6 +845,8 @@ To turn translation on, you must:
- ensure that your application sets the :term:`locale name` correctly.
+.. _adding_a_translation_directory:
+
Adding a Translation Directory
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -863,48 +865,28 @@ found within all ``LC_MESSAGES`` directories within each locale
directory in the translation directory) within your :mod:`pyramid`
application to be available to use for translation services.
-You may add a translation directory to your application's
-configuration using either imperative configuration or ZCML.
-
-.. topic:: Using Imperative Configuration
-
- You can add a translation directory imperatively by using the
- :meth:`pyramid.configuration.Configurator.add_translation_dirs`
- during application startup.
-
- For example:
-
- .. code-block:: python
- :linenos:
-
- from pyramid.configuration import Configurator
- config.begin()
- config.add_translation_dirs('my.application:locale/',
- 'another.application:locale/')
- ...
- config.end()
-
- A message catalog in a translation directory added via
- :meth:`pyramid.configuration.Configurator.add_translation_dirs`
- will be merged into translations from a 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 imperatively by using the
+:meth:`pyramid.configuration.Configurator.add_translation_dirs` during
+application startup. 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 pyramid.configuration import Configurator
+ config.begin()
+ config.add_translation_dirs('my.application:locale/',
+ 'another.application:locale/')
+ ...
+ config.end()
- <translationdir dir="my.application:locale/"/>
+A message catalog in a translation directory added via
+:meth:`pyramid.configuration.Configurator.add_translation_dirs`
+will be merged into translations from a 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
- a message catalog added earlier if both translation directories
- contain translations for the same locale and :term:`translation
- domain`.
+.. note:: You can also add a translation directory via ZCML. See
+ :ref:`zcml_adding_a_translation_directory`
Setting the Locale
~~~~~~~~~~~~~~~~~~
@@ -1007,46 +989,32 @@ If a locale negotiator returns ``None``, it signifies to
used.
You may add your newly created locale negotiator to your application's
-configuration using either imperative configuration or ZCML.
+configuration by passing an object which can act as the negotiator (or a
+:term:`dotted Python name` referring to the object) as the
+``locale_negotiator`` argument of the
+:class:`pyramid.configuration.Configurator` instance during application
+startup. For example:
-.. topic:: Using Imperative Configuration
-
- Pass an object which can act as the negotiator (or a :term:`dotted
- Python name` referring to the object) as the ``locale_negotiator``
- argument of the :class:`pyramid.configuration.Configurator`
- instance during application startup.
-
- For example:
-
- .. code-block:: python
- :linenos:
-
- from pyramid.configuration import Configurator
- config = Configurator(locale_negotiator=my_locale_negotiator)
-
- Alternately, use the
- :meth:`pyramid.configuration.Configurator.set_locale_negotiator`
- method.
-
- For example:
-
- .. code-block:: python
- :linenos:
+.. code-block:: python
+ :linenos:
- from pyramid.configuration import Configurator
- config = Configurator()
- config.begin()
- config.set_locale_negotiator(my_locale_negotiator)
- config.end()
+ from pyramid.configuration import Configurator
+ config = Configurator(locale_negotiator=my_locale_negotiator)
-.. topic:: Using ZCML
+Alternately, use the
+:meth:`pyramid.configuration.Configurator.set_locale_negotiator`
+method.
- You can add a locale negotiator via ZCML by using the
- :ref:`localenegotiator_directive` ZCML directive:
+For example:
- .. code-block:: xml
- :linenos:
+.. code-block:: python
+ :linenos:
- <localenegotiator
- negotiator="my_application.my_module.my_locale_negotiator"/>
+ from pyramid.configuration import Configurator
+ config = Configurator()
+ config.begin()
+ config.set_locale_negotiator(my_locale_negotiator)
+ config.end()
+.. note:: You can also add a custom locale negotiator via ZCML. See
+ :ref:`zcml_adding_a_locale_negotiator`