Skip to content

Commit

Permalink
Rename.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcdonc committed Apr 24, 2010
1 parent cbc7b2a commit 753add8
Show file tree
Hide file tree
Showing 17 changed files with 120 additions and 110 deletions.
4 changes: 2 additions & 2 deletions CHANGES.txt
@@ -1,5 +1,5 @@
internatl
=========
translationstring
=================

0.0 (unreleased)
----------------
Expand Down
23 changes: 15 additions & 8 deletions README.txt
@@ -1,10 +1,17 @@
internatl
=========
translationstring
=================

A low-level utility library for internationalization related to
`Chameleon <http://chameleon.repoze.org>`_, `BFG
<http://bfg.repoze.org>`_.
A library used by various `Repoze <http://repoze.org>`_ packages for
internationalization (i18n) duties related to translation.

Please see `http://docs.repoze.org/internatl
<http://docs.repoze.org/internatl>`_ or docs/index.rst for the
documentation.
This package provides a *translation string* class, a *translation
string factory* class, translation and pluralization primitives, and a
utility that helps `Chameleon <http://chameleon.repoze.org>`_
templates use translation facilities of this package. It does not
depend on `Babel <http://babel.edgewall.org>`_, but its translation
and pluralization services are meant to work best when provided with
an instance of the ``babel.support.Translations`` class.

Please see `http://docs.repoze.org/translationstring
<http://docs.repoze.org/translationstring>`_ or the ``docs/index.rst``
file in this package for the documentation.
4 changes: 2 additions & 2 deletions docs/api.rst
@@ -1,9 +1,9 @@
.. _internatl_module:
.. _translationstring_module:

API Documentation
-----------------

.. automodule:: internatl
.. automodule:: translationstring

.. autoclass:: TranslationString
:members:
Expand Down
18 changes: 9 additions & 9 deletions docs/chameleon.rst
@@ -1,16 +1,16 @@
Chameleon Translate Function Support
=====================================

:func:`internatl.ChameleonTranslate` is a function which returns a
callable suitable for use as the ``translate`` argument to various
``PageTemplate*`` constructors.
:func:`translationstring.ChameleonTranslate` is a function which
returns a callable suitable for use as the ``translate`` argument to
various ``PageTemplate*`` constructors.

.. code-block:: python
:linenos:
from chameleon.zpt.template import PageTemplate
from internatl import ChameleonTranslate
from internatl import Translator
from translationstring import ChameleonTranslate
from translationstring import Translator
import gettext
translations = gettext.translations(...)
Expand All @@ -20,8 +20,8 @@ callable suitable for use as the ``translate`` argument to various
The ``translator`` provided should be a callable which accepts a
single argument ``translation_string`` ( a
:class:`internatl.TranslationString` instance) which returns a
:class:`translationstring.TranslationString` instance) which returns a
``unicode`` object as a translation; usually the result of calling
:func:`internatl.Translator`. ``translator`` may also optionally be
``None``, in which case no translation is performed (the ``msgid`` or
``default`` value is returned untranslated).
:func:`translationstring.Translator`. ``translator`` may also
optionally be ``None``, in which case no translation is performed (the
``msgid`` or ``default`` value is returned untranslated).
8 changes: 4 additions & 4 deletions docs/conf.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# internatl documentation build configuration file
# translationstring documentation build configuration file
#
# This file is execfile()d with the current directory set to its containing
# dir.
Expand Down Expand Up @@ -48,7 +48,7 @@
master_doc = 'index'

# General substitutions.
project = 'internatl'
project = 'translationstring'
copyright = '2010, Repoze Developers <repoze-dev@lists.repoze.org>'

# The default replacements for |version| and |release|, also used in various
Expand Down Expand Up @@ -159,7 +159,7 @@
#html_file_suffix = ''

# Output file base name for HTML help builder.
htmlhelp_basename = 'internatldoc'
htmlhelp_basename = 'translationstringdoc'


# Options for LaTeX output
Expand All @@ -175,7 +175,7 @@
# (source start file, target name, title,
# author, document class [howto/manual]).
latex_documents = [
('index', 'internatl.tex', 'internatl Documentation',
('index', 'translationstring.tex', 'translationstring Documentation',
'Repoze Developers', 'manual'),
]

Expand Down
17 changes: 9 additions & 8 deletions docs/glossary.rst
Expand Up @@ -7,13 +7,14 @@ Glossary
:sorted:

Translation String
An instance of :class:`internatl.TranslationString`, which is a
class that behaves like a Unicode string, but has several extra
attributes such as ``domain``, ``msgid``, and ``mapping`` for use
during translation. Translation strings are usually created by
hand within software, but are sometimes created on the behalf of
the system for automatic template translation. For more
information, see :ref:`internatl_module`.
An instance of :class:`translationstring.TranslationString`,
which is a class that behaves like a Unicode string, but has
several extra attributes such as ``domain``, ``msgid``, and
``mapping`` for use during translation. Translation strings are
usually created by hand within software, but are sometimes
created on the behalf of the system for automatic template
translation. For more information, see
:ref:`translationstring_module`.

Translation String Factory
A factory for generating :term:`translation string` objects which
Expand Down Expand Up @@ -47,7 +48,7 @@ Glossary

Gettext
The GNU `gettext <http://www.gnu.org/software/gettext/>`_
library, used by the :mod:`internatl` locale translation
library, used by the :mod:`translationstring` locale translation
machinery.

Translator
Expand Down
14 changes: 7 additions & 7 deletions docs/pluralization.rst
@@ -1,7 +1,7 @@
Pluralization
=============

:func:`internatl.Pluralizer` provides a gettext "plural forms"
:func:`translationstring.Pluralizer` provides a gettext "plural forms"
pluralization service.

It is called like so:
Expand All @@ -10,7 +10,7 @@ It is called like so:
:linenos:
import gettext
from internatl import Pluralizer
from translationstring import Pluralizer
translations = gettext.translations(.. the right arguments ...)
pluralizer = Pluralizer(translations)
Expand Down Expand Up @@ -45,10 +45,10 @@ singular form, translated, as necessary.
If ``translations`` is ``None``, a :class:`gettext.NullTranslations`
object is created for the pluralizer to use.

The :func:`internatl.Pluralizer` function accepts an additional
optional argument named ``policy``. ``policy`` should be a callable
which accepts five arguments: ``translations``, ``singular`` and
``plural``, ``n`` and ``domain``. It must perform the actual
The :func:`translationstring.Pluralizer` function accepts an
additional optional argument named ``policy``. ``policy`` should be a
callable which accepts five arguments: ``translations``, ``singular``
and ``plural``, ``n`` and ``domain``. It must perform the actual
pluralization lookup. If ``policy`` is ``None``, the
:func:`internatl.dungettext_policy` policy will be used.
:func:`translationstring.dungettext_policy` policy will be used.

26 changes: 13 additions & 13 deletions docs/translation.rst
Expand Up @@ -3,8 +3,8 @@
Translation
===========

:mod:`internatl` provides a function named
:func:`internatl.Translator` which is used to create a
:mod:`translationstring` provides a function named
:func:`translationstring.Translator` which is used to create a
:term:`translator` object.

It is called like so:
Expand All @@ -13,7 +13,7 @@ It is called like so:
:linenos:
import gettext
from internatl import Translator
from translationstring import Translator
translations = gettext.translations(.. the right arguments ...)
translator = Translator(translations)
Expand All @@ -32,8 +32,8 @@ object provided and interpolate the result.
:linenos:
from gettext import translations
from internatl import Translator
from internatl import TranslationString
from translationstring import Translator
from translationstring import TranslationString
t = translations(.. the right arguments ...)
translator = Translator(t)
Expand All @@ -54,17 +54,17 @@ when the ``tstring`` argument is not a translation string.
:linenos:
from gettext import translations
from internatl import Translator
from internatl import TranslationString
from translationstring import Translator
from translationstring import TranslationString
t = translations(.. the right arguments ...)
translator = Translator(t)
translator('Add ${number}', domain='foo', mapping={'number':1})
The :func:`internatl.Translator` function accepts an additional
optional argument named ``policy``. ``policy`` should be a callable
which accepts three arguments: ``translations``, ``tstring`` and
``domain``. It must perform the actual translation lookup. If
``policy`` is ``None``, the :func:`internatl.dugettext_policy` policy
will be used.
The :func:`translationstring.Translator` function accepts an
additional optional argument named ``policy``. ``policy`` should be a
callable which accepts three arguments: ``translations``, ``tstring``
and ``domain``. It must perform the actual translation lookup. If
``policy`` is ``None``, the :func:`translationstring.dugettext_policy`
policy will be used.

38 changes: 19 additions & 19 deletions docs/tstrings.rst
Expand Up @@ -18,24 +18,24 @@ Using The ``TranslationString`` Class
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The most primitive way to create a translation string is to use the
:class:`internatl.TranslationString` callable:
:class:`translationstring.TranslationString` callable:

.. code-block:: python
:linenos:
from internatl import TranslationString
from translationstring import TranslationString
ts = TranslationString('Add')
This creates a Unicode-like object that is a
:class:`internatl.TranslationString`.
:class:`translationstring.TranslationString`.

.. note::

For people familiar with Zope internationalization, a
TranslationString is a lot like a ``zope.i18nmessageid.Message``
object. It is not a subclass, however.

The first argument to :class:`internatl.TranslationString` is the
The first argument to :class:`translationstring.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 msgid may optionally
Expand All @@ -44,27 +44,27 @@ contain *replacement markers*. For instance:
.. code-block:: python
:linenos:
from internatl import TranslationString
from translationstring import TranslationString
ts = TranslationString('Add ${number}')
Within the string above, ``${stuff}`` is a replacement marker. It
will be replaced by whatever is in the *mapping* for a translation
string when the :meth:`internatl.TranslationString.interpolate` method
string when the :meth:`translationstring.TranslationString.interpolate` method
is called. The mapping may be supplied at the same time as the
replacement marker itself:

.. code-block:: python
:linenos:
from internatl import TranslationString
from translationstring import TranslationString
ts = TranslationString('Add ${number}', mapping={'number':1})
You may interpolate a translation string with a mapping:

.. code-block:: python
:linenos:
from internatl import TranslationString
from translationstring import TranslationString
ts = TranslationString('Add ${number}', mapping={'number':1})
result = ts.interpolate()
Expand All @@ -80,7 +80,7 @@ Replacement markers may also be spelled without squiggly braces:
.. code-block:: python
:linenos:
from internatl import TranslationString
from translationstring import TranslationString
ts = TranslationString('Add $number', mapping={'number':1})
The ``Add $number`` msgid above is equivalent to ``Add ${number}``.
Expand All @@ -92,7 +92,7 @@ translations of the same msgid, in case they conflict.
.. code-block:: python
:linenos:
from internatl import TranslationString
from translationstring import TranslationString
ts = TranslationString('Add ${number}', mapping={'number':1},
domain='form')
Expand Down Expand Up @@ -121,7 +121,7 @@ identifiers unrelated to their default text:
.. code-block:: python
:linenos:
from internatl import TranslationString
from translationstring import TranslationString
ts = TranslationString('add-number', default='Add ${number}',
domain='form', mapping={'number':1})
Expand All @@ -132,15 +132,15 @@ Using the ``TranslationStringFactory`` Class
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Another way to generate a translation string is to use the
:attr:`internatl.TranslationStringFactory` object. This object is a
:attr:`translationstring.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:

.. code-block:: python
:linenos:
from internatl import TranslationStringFactory
from translationstring import TranslationStringFactory
_ = TranslationStringFactory('bfg')
ts = _('Add ${number}', msgid='add-number', mapping={'number':1})
Expand All @@ -149,11 +149,11 @@ generated by using it. For example:
file generation tools.

After assigning ``_`` to the result of a
:func:`internatl.TranslationStringFactory`, the subsequent
:func:`translationstring.TranslationStringFactory`, the subsequent
result of calling ``_`` will be a
:class:`internatl.TranslationString` instance. Even though a
:class:`translationstring.TranslationString` instance. Even though a
``domain`` value was not passed to ``_` (as would have been necessary
if the :class:`internatl.TranslationString` constructor were
if the :class:`translationstring.TranslationString` constructor were
used instead of a translation string factory), the ``domain``
attribute of the resulting translation string will be ``bfg``. As a
result, the previous code example is completely equivalent (except for
Expand All @@ -162,21 +162,21 @@ spelling) to:
.. code-block:: python
:linenos:
from internatl import TranslationString as _
from translationstring import TranslationString as _
ts = _('Add ${number}', msgid='add-number', mapping={'number':1},
domain='bfg')
You can set up your own translation string factory much like the one
provided above by using the
:class:`internatl.TranslationStringFactory` class. For example,
:class:`translationstring.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:

.. code-block:: python
:linenos:
from internatl import TranslationStringFactory
from translationstring import TranslationStringFactory
_ = TranslationStringFactory('form')
ts = _('Add ${number}', msgid='add-number', mapping={'number':1})
Expand Down
4 changes: 2 additions & 2 deletions setup.cfg
Expand Up @@ -3,7 +3,7 @@ zip_ok = false

[nosetests]
match=^test
where=internatl
where=translationstring
nocapture=1
cover-package=internatl
cover-package=translationstring
cover-erase=1

0 comments on commit 753add8

Please sign in to comment.