summaryrefslogtreecommitdiff
path: root/docs/narr/i18n.rst
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2010-12-01 19:33:06 -0500
committerChris McDonough <chrism@plope.com>2010-12-01 19:33:06 -0500
commitf1ffaeeff438aa2ea768c508fe38e3dd108b9369 (patch)
tree6ff2b0d0063be11ef0b3fa65232a37f629331165 /docs/narr/i18n.rst
parentd195074f2c6ef704926cf56de4e26e36e11ee758 (diff)
parent1220f3b8f869e4caf298d9acb5e5fffe0a86129e (diff)
downloadpyramid-f1ffaeeff438aa2ea768c508fe38e3dd108b9369.tar.gz
pyramid-f1ffaeeff438aa2ea768c508fe38e3dd108b9369.tar.bz2
pyramid-f1ffaeeff438aa2ea768c508fe38e3dd108b9369.zip
Merge branch 'master' into twophase
Diffstat (limited to 'docs/narr/i18n.rst')
-rw-r--r--docs/narr/i18n.rst35
1 files changed, 21 insertions, 14 deletions
diff --git a/docs/narr/i18n.rst b/docs/narr/i18n.rst
index 9e2071872..603b08cef 100644
--- a/docs/narr/i18n.rst
+++ b/docs/narr/i18n.rst
@@ -104,7 +104,9 @@ right translator file on the filesystem which contains translations
for a given domain. In this case, if it were trying to translate
our msgid to German, it might try to find a translation from a
:term:`gettext` file within a :term:`translation directory` like this
-one::
+one:
+
+.. code-block:: text
locale/de/LC_MESSAGES/form.mo
@@ -268,7 +270,7 @@ If the :term:`virtualenv` into which you've installed your
:app:`Pyramid` application lives in ``/my/virtualenv``, you can
install Babel like so:
-.. code-block:: bash
+.. code-block:: text
$ cd /my/virtualenv
$ bin/easy_install Babel
@@ -280,7 +282,7 @@ If the :term:`virtualenv` into which you've installed your
:app:`Pyramid` application lives in ``C:\my\virtualenv``, you can
install Babel like so:
-.. code-block:: bash
+.. code-block:: text
C> cd \my\virtualenv
C> bin\easy_install Babel
@@ -307,9 +309,9 @@ In particular, add the ``Babel`` distribution to the
:linenos:
setup(name="mypackage",
- ...
+ # ...
install_requires = [
- ....
+ # ...
'Babel',
],
message_extractors = { '.': [
@@ -336,8 +338,7 @@ message catalog template from the code and :term:`Chameleon` templates
which reside in your :app:`Pyramid` application. You run a
``setup.py`` command to extract the messages:
-.. code-block:: bash
- :linenos:
+.. code-block:: text
$ cd /place/where/myapplication/setup.py/lives
$ mkdir -p myapplication/locale
@@ -424,7 +425,9 @@ in the ``.pot`` file, you need to generate at least one ``.po`` file.
A ``.po`` file represents translations of a particular set of messages
to a particular locale. Initialize a ``.po`` file for a specific
locale from a pre-generated ``.pot`` template by using the ``setup.py
-init_catalog`` command::
+init_catalog`` command:
+
+.. code-block:: text
$ cd /place/where/myapplication/setup.py/lives
$ python setup.py init_catalog -l es
@@ -455,7 +458,7 @@ changed messages can also be translated or re-translated.
First, regenerate the ``.pot`` file as per :ref:`extracting_messages`.
Then use the ``setup.py update_catalog`` command.
-.. code-block:: bash
+.. code-block:: text
$ cd /place/where/myapplication/setup.py/lives
$ python setup.py update_catalog
@@ -469,7 +472,9 @@ Compiling a Message Catalog File
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Finally, to prepare an application for performing actual runtime
-translations, compile ``.po`` files to ``.mo`` files::
+translations, compile ``.po`` files to ``.mo`` files:
+
+.. code-block:: text
$ cd /place/where/myapplication/setup.py/lives
$ python setup.py compile_catalog
@@ -812,16 +817,18 @@ mechanism:
Allow a deployer to modify your application's PasteDeploy .ini file:
.. code-block:: ini
+ :linenos:
[app:main]
use = egg:MyProject#app
- ...
+ # ...
available_languages = fr de en ru
Then as a part of the code of a custom :term:`locale negotiator`:
-.. code-block:: py
-
+.. code-block:: python
+ :linenos:
+
from pyramid.threadlocal import get_current_registry
settings = get_current_registry().settings
languages = settings['available_languages'].split()
@@ -877,7 +884,7 @@ application startup. For example:
config.begin()
config.add_translation_dirs('my.application:locale/',
'another.application:locale/')
- ...
+ # ...
config.end()
A message catalog in a translation directory added via