From d30a83540d98bb803caca74b94ae75f88dd3154b Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Mon, 27 Dec 2010 01:05:14 -0500 Subject: remove inappropriate use of begin/end --- docs/narr/i18n.rst | 5 ----- 1 file changed, 5 deletions(-) (limited to 'docs/narr/i18n.rst') diff --git a/docs/narr/i18n.rst b/docs/narr/i18n.rst index d8cc5cb1c..c2a5b8ce7 100644 --- a/docs/narr/i18n.rst +++ b/docs/narr/i18n.rst @@ -881,11 +881,8 @@ application startup. For example: :linenos: from pyramid.config 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.config.Configurator.add_translation_dirs` @@ -1020,9 +1017,7 @@ For example: from pyramid.config 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` -- cgit v1.2.3 From 4d4173ff808b33a3c29ee5874751d4da25ddcca0 Mon Sep 17 00:00:00 2001 From: Casey Duncan Date: Sat, 15 Jan 2011 23:30:42 -0700 Subject: clarify by promoting long parenthetical to its own sentence --- docs/narr/i18n.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'docs/narr/i18n.rst') diff --git a/docs/narr/i18n.rst b/docs/narr/i18n.rst index c2a5b8ce7..c7ed18e4c 100644 --- a/docs/narr/i18n.rst +++ b/docs/narr/i18n.rst @@ -867,11 +867,11 @@ which itself includes an ``LC_MESSAGES`` directory. Each Each ``.mo`` file represents a :term:`message catalog`, which is used to provide translations to your application. -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 :app:`Pyramid` -application to be available to use for translation services. +Adding a :term:`translation directory` registers all of its constituent +:term:`message catalog` files within your :app:`Pyramid` application to +be available to use for translation services. This includes all of the +``.mo`` files found within all ``LC_MESSAGES`` directories within each +locale directory in the translation directory. You can add a translation directory imperatively by using the :meth:`pyramid.config.Configurator.add_translation_dirs` during -- cgit v1.2.3 From c9c3c487bcaedeca97bb6463a00188b0dc01203a Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Tue, 18 Jan 2011 12:25:56 -0500 Subject: - Most references to ZCML in narrative chapters have been removed or redirected to ``pyramid_zcml`` locations. --- docs/narr/i18n.rst | 5 ----- 1 file changed, 5 deletions(-) (limited to 'docs/narr/i18n.rst') diff --git a/docs/narr/i18n.rst b/docs/narr/i18n.rst index c2a5b8ce7..e1b6acc7b 100644 --- a/docs/narr/i18n.rst +++ b/docs/narr/i18n.rst @@ -890,9 +890,6 @@ 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 ~~~~~~~~~~~~~~~~~~ @@ -1019,5 +1016,3 @@ For example: config = Configurator() config.set_locale_negotiator(my_locale_negotiator) -.. note:: You can also add a custom locale negotiator via ZCML. See - :ref:`zcml_adding_a_locale_negotiator` -- cgit v1.2.3 From ddf07e7f1486b195bc337a3035f6852980a4d3d7 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Fri, 21 Jan 2011 02:43:02 -0500 Subject: - Add (minimal) documentation about using I18N within Mako templates to "Internationalization and Localization" narrative chapter. --- docs/narr/i18n.rst | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'docs/narr/i18n.rst') diff --git a/docs/narr/i18n.rst b/docs/narr/i18n.rst index 83973a17e..02e7dba64 100644 --- a/docs/narr/i18n.rst +++ b/docs/narr/i18n.rst @@ -735,6 +735,13 @@ this support out of the box and may need special code to do an equivalent. For those, you can always use the more manual translation facility described in :ref:`performing_a_translation`. +Mako Pyramid I18N Support +------------------------- + +See `Alexandre Bourget's blog entry +`_ +to add idiomatic I18N support to :term:`Mako` templates. + .. index:: single: localization deployment settings single: default_locale_name -- cgit v1.2.3 From 8864e043a683f22f5ec316f17a146fedaa3373da Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Fri, 21 Jan 2011 13:03:29 -0500 Subject: depend on intersphinx to point at Mako i18n recipe --- docs/narr/i18n.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'docs/narr/i18n.rst') diff --git a/docs/narr/i18n.rst b/docs/narr/i18n.rst index 02e7dba64..4871fe400 100644 --- a/docs/narr/i18n.rst +++ b/docs/narr/i18n.rst @@ -738,9 +738,8 @@ facility described in :ref:`performing_a_translation`. Mako Pyramid I18N Support ------------------------- -See `Alexandre Bourget's blog entry -`_ -to add idiomatic I18N support to :term:`Mako` templates. +:`mako_i18n` is a cookbook recipe which explains how to add idiomatic I18N +support to :term:`Mako` templates. .. index:: single: localization deployment settings -- cgit v1.2.3 From 4cf41f4f042067b3bb0001436640ab52b15f3249 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Fri, 21 Jan 2011 13:14:32 -0500 Subject: point at Pyramid Cookbook explicitly --- docs/narr/i18n.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docs/narr/i18n.rst') diff --git a/docs/narr/i18n.rst b/docs/narr/i18n.rst index 4871fe400..7bfd29631 100644 --- a/docs/narr/i18n.rst +++ b/docs/narr/i18n.rst @@ -738,8 +738,8 @@ facility described in :ref:`performing_a_translation`. Mako Pyramid I18N Support ------------------------- -:`mako_i18n` is a cookbook recipe which explains how to add idiomatic I18N -support to :term:`Mako` templates. +:ref:`mako_i18n` is a recipe within the :term:`Pyramid Cookbook` which +explains how to add idiomatic I18N support to :term:`Mako` templates. .. index:: single: localization deployment settings -- cgit v1.2.3 From 70acd25f40f32fc6cbb3b5d38a695b8982b52a31 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Thu, 27 Jan 2011 23:06:55 -0500 Subject: module name contractions --- docs/narr/i18n.rst | 45 ++++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 23 deletions(-) (limited to 'docs/narr/i18n.rst') diff --git a/docs/narr/i18n.rst b/docs/narr/i18n.rst index 7bfd29631..9a43e8772 100644 --- a/docs/narr/i18n.rst +++ b/docs/narr/i18n.rst @@ -59,7 +59,7 @@ This creates a Unicode-like object that is a TranslationString. :term:`Django` i18n, using a TranslationString is a lot like using "lazy" versions of related gettext APIs. -The first argument to :class:`pyramid.i18n.TranslationString` is +The first argument to :class:`~pyramid.i18n.TranslationString` is the ``msgid``; it is required. It represents the key into the translation mappings provided by a particular localization. The ``msgid`` argument must be a Unicode object or an ASCII string. The @@ -139,7 +139,7 @@ Using the ``TranslationStringFactory`` Class ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Another way to generate a translation string is to use the -:attr:`pyramid.i18n.TranslationStringFactory` object. This object +:attr:`~pyramid.i18n.TranslationStringFactory` object. This object is a *translation string factory*. Basically a translation string factory presets the ``domain`` value of any :term:`translation string` generated by using it. For example: @@ -156,11 +156,11 @@ generated by using it. For example: file generation tools. After assigning ``_`` to the result of a -:func:`pyramid.i18n.TranslationStringFactory`, the subsequent result -of calling ``_`` will be a :class:`pyramid.i18n.TranslationString` +:func:`~pyramid.i18n.TranslationStringFactory`, the subsequent result +of calling ``_`` will be a :class:`~pyramid.i18n.TranslationString` instance. Even though a ``domain`` value was not passed to ``_`` (as would have been necessary if the -:class:`pyramid.i18n.TranslationString` constructor were used instead +:class:`~pyramid.i18n.TranslationString` constructor were used instead of a translation string factory), the ``domain`` attribute of the resulting translation string will be ``pyramid``. As a result, the previous code example is completely equivalent (except for spelling) @@ -175,7 +175,7 @@ to: You can set up your own translation string factory much like the one provided above by using the -:class:`pyramid.i18n.TranslationStringFactory` class. For example, +:class:`~pyramid.i18n.TranslationStringFactory` class. For example, if you'd like to create a translation string factory which presets the ``domain`` value of generated translation strings to ``form``, you'd do something like this: @@ -491,13 +491,12 @@ translations will be available to :app:`Pyramid`. Using a Localizer ----------------- -A :term:`localizer` is an object that allows you to perform -translation or pluralization "by hand" in an application. You may use -the :func:`pyramid.i18n.get_localizer` function to obtain a -:term:`localizer`. :func:`pyramid.i18n.get_localizer`. This -function will return either the localizer object implied by the active -:term:`locale negotiator` or a default localizer object if no explicit -locale negotiator is registered. +A :term:`localizer` is an object that allows you to perform translation or +pluralization "by hand" in an application. You may use the +:func:`pyramid.i18n.get_localizer` function to obtain a :term:`localizer`. +This function will return either the localizer object implied by the active +:term:`locale negotiator` or a default localizer object if no explicit locale +negotiator is registered. .. code-block:: python :linenos: @@ -534,7 +533,7 @@ translation in a view component of an application might look like so: translated = localizer.translate(ts) # translation string # ... use translated ... -The :func:`pyramid.i18n.get_localizer` function will return a +The :func:`~pyramid.i18n.get_localizer` function will return a :class:`pyramid.i18n.Localizer` object bound to the locale name represented by the request. The translation returned from its :meth:`pyramid.i18n.Localizer.translate` method will depend on the @@ -612,9 +611,9 @@ locale negotiator returns ``None``. You can change the default locale name by changing the ``default_locale_name`` setting; see :ref:`default_locale_name_setting`. -Once :func:`pyramid.i18n.get_locale_name` is first run, the locale +Once :func:`~pyramid.i18n.get_locale_name` is first run, the locale name is stored on the request object. Subsequent calls to -:func:`pyramid.i18n.get_locale_name` will return the stored locale +:func:`~pyramid.i18n.get_locale_name` will return the stored locale name without invoking the :term:`locale negotiator`. To avoid this caching, you can use the :func:`pyramid.i18n.negotiate_locale_name` function: @@ -641,7 +640,7 @@ You can also obtain the locale name related to a request using the Obtaining the locale name as an attribute of a localizer is equivalent to obtaining a locale name by calling the -:func:`pyramid.i18n.get_locale_name` function. +:func:`~pyramid.i18n.get_locale_name` function. .. index:: single: date and currency formatting (i18n) @@ -753,7 +752,7 @@ Localization-Related Deployment Settings A :app:`Pyramid` application will have a ``default_locale_name`` setting. This value represents the :term:`default locale name` used when the :term:`locale negotiator` returns ``None``. Pass it to the -:mod:`pyramid.config.Configurator` constructor at startup +:mod:`~pyramid.config.Configurator` constructor at startup time: .. code-block:: python @@ -891,7 +890,7 @@ application startup. For example: 'another.application:locale/') A message catalog in a translation directory added via -:meth:`pyramid.config.Configurator.add_translation_dirs` +:meth:`~pyramid.config.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`. @@ -937,8 +936,8 @@ a particular request. A locale negotiator is a bit of code which accepts a request and which returns a :term:`locale name`. It is consulted when :meth:`pyramid.i18n.Localizer.translate` or :meth:`pyramid.i18n.Localizer.pluralize` is invoked. It is also -consulted when :func:`pyramid.i18n.get_locale_name` or -:func:`pyramid.i18n.negotiate_locale_name` is invoked. +consulted when :func:`~pyramid.i18n.get_locale_name` or +:func:`~pyramid.i18n.negotiate_locale_name` is invoked. .. _default_locale_negotiator: @@ -949,7 +948,7 @@ Most applications can make use of the default locale negotiator, which requires no additional coding or configuration. The default locale negotiator implementation named -:class:`pyramid.i18n.default_locale_negotiator` uses the following +:class:`~pyramid.i18n.default_locale_negotiator` uses the following set of steps to dermine the locale name. - First, the negotiator looks for the ``_LOCALE_`` attribute of the @@ -1000,7 +999,7 @@ You may add your newly created locale negotiator to your application's 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.config.Configurator` instance during application +:class:`~pyramid.config.Configurator` instance during application startup. For example: .. code-block:: python -- cgit v1.2.3 From df83bb2ba1d70ee0af6533260fb079fc666caa3b Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Sun, 30 Jan 2011 13:14:43 -0500 Subject: remove direct reference to pyramid_cookbook; doesnt work in printed version --- docs/narr/i18n.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'docs/narr/i18n.rst') diff --git a/docs/narr/i18n.rst b/docs/narr/i18n.rst index 9a43e8772..141b04704 100644 --- a/docs/narr/i18n.rst +++ b/docs/narr/i18n.rst @@ -737,8 +737,9 @@ facility described in :ref:`performing_a_translation`. Mako Pyramid I18N Support ------------------------- -:ref:`mako_i18n` is a recipe within the :term:`Pyramid Cookbook` which -explains how to add idiomatic I18N support to :term:`Mako` templates. +There exists a recipe within the :term:`Pyramid Cookbook` named "Mako +Internationalization" which explains how to add idiomatic I18N support to +:term:`Mako` templates. .. index:: single: localization deployment settings -- cgit v1.2.3 From eea7b42a57fe75dc82629b90be3f2546fb8dc4bd Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Sun, 30 Jan 2011 17:24:36 -0500 Subject: fix too-long lines --- docs/narr/i18n.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'docs/narr/i18n.rst') diff --git a/docs/narr/i18n.rst b/docs/narr/i18n.rst index 141b04704..e7a4f61c0 100644 --- a/docs/narr/i18n.rst +++ b/docs/narr/i18n.rst @@ -344,7 +344,8 @@ which reside in your :app:`Pyramid` application. You run a $ mkdir -p myapplication/locale $ python setup.py extract_messages -The message catalog ``.pot`` template will end up in +The message catalog ``.pot`` template will end up in: + ``myapplication/locale/myapplication.pot``. Translation Domains @@ -432,7 +433,8 @@ init_catalog`` command: $ cd /place/where/myapplication/setup.py/lives $ python setup.py init_catalog -l es -By default, the message catalog ``.po`` file will end up in +By default, the message catalog ``.po`` file will end up in: + ``myapplication/locale/es/LC_MESSAGES/myapplication.po``. Once the file is there, it can be worked on by a human translator. -- cgit v1.2.3 From 86bbe8bddb1a0e62e7cd811cf2df0d57d72827dc Mon Sep 17 00:00:00 2001 From: Christopher Lambacher Date: Sat, 12 Feb 2011 17:27:59 -0500 Subject: Add make_localizer function & docs & tests --- docs/narr/i18n.rst | 3 +++ 1 file changed, 3 insertions(+) (limited to 'docs/narr/i18n.rst') diff --git a/docs/narr/i18n.rst b/docs/narr/i18n.rst index e7a4f61c0..218b7a2b4 100644 --- a/docs/narr/i18n.rst +++ b/docs/narr/i18n.rst @@ -508,6 +508,9 @@ negotiator is registered. def aview(request): locale = get_localizer(request) +.. note:: If you need to create a localizer for a locale use the + :func:`pyramid.i18n.make_localizer` function. + .. index:: single: translating (i18n) -- cgit v1.2.3