Permalink
Browse files

Rename.

  • Loading branch information...
1 parent cbc7b2a commit 753add8b69ab548ff04329fe560c948287cda8bf @mcdonc mcdonc committed Apr 24, 2010
View
4 CHANGES.txt
@@ -1,5 +1,5 @@
-internatl
-=========
+translationstring
+=================
0.0 (unreleased)
----------------
View
23 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.
View
4 docs/api.rst
@@ -1,9 +1,9 @@
-.. _internatl_module:
+.. _translationstring_module:
API Documentation
-----------------
-.. automodule:: internatl
+.. automodule:: translationstring
.. autoclass:: TranslationString
:members:
View
18 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(...)
@@ -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).
View
8 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.
@@ -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
@@ -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
@@ -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'),
]
View
17 docs/glossary.rst
@@ -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
@@ -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
View
14 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:
@@ -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)
@@ -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.
View
26 docs/translation.rst
@@ -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:
@@ -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)
@@ -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)
@@ -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.
View
38 docs/tstrings.rst
@@ -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
@@ -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()
@@ -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}``.
@@ -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')
@@ -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})
@@ -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})
@@ -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
@@ -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})
View
4 setup.cfg
@@ -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
View
4 setup.py
@@ -9,7 +9,7 @@
requires = []
-setup(name='internatl',
+setup(name='translationstring',
version='0.1',
description=('Utility library for i18n relied on by various Repoze '
'packages'),
@@ -30,6 +30,6 @@
zip_safe=False,
tests_require = requires + ['Babel'],
install_requires = requires,
- test_suite="internatl",
+ test_suite="translationstring",
)
View
26 internatl/__init__.py → translationstring/__init__.py
@@ -96,11 +96,12 @@ def TranslationStringFactory(domain):
without requiring that each call to the factory be passed a
``domain`` value. A single argument is passed to this class'
constructor: ``domain``. This value will be used as the
- ``domain`` values of :class:`internatl.TranslationString` objects
- generated by the ``__call__`` of this class. The ``msgid``,
- ``mapping``, and ``default`` values provided to the ``__call__``
- method of an instance of this class have the meaning as described
- by the constructor of the :class:`internatl.TranslationString`"""
+ ``domain`` values of :class:`translationstring.TranslationString`
+ objects generated by the ``__call__`` of this class. The
+ ``msgid``, ``mapping``, and ``default`` values provided to the
+ ``__call__`` method of an instance of this class have the meaning
+ as described by the constructor of the
+ :class:`translationstring.TranslationString`"""
def create(msgid, mapping=None, default=None):
""" Provided a msgid (Unicode object or :term:`translation
string`) and optionally a mapping object, and a *default
@@ -118,10 +119,11 @@ def ChameleonTranslate(translator):
translation. A single required argument ``translator`` is
passsed. The ``translator`` provided should be a callable which
accepts a single argument ``translation_string`` ( a
- :class:`internatl.TranslationString` instance) which returns a
- ``unicode`` object as a translation. ``translator`` may also
- optionally be ``None``, in which case no translation is performed
- (the ``msgid`` or ``default`` value is returned untranslated).
+ :class:`translationstring.TranslationString` instance) which
+ returns a ``unicode`` object as a translation. ``translator`` may
+ also optionally be ``None``, in which case no translation is
+ performed (the ``msgid`` or ``default`` value is returned
+ untranslated).
"""
def translate(msgid, domain=None, mapping=None, context=None,
target_language=None, default=None):
@@ -169,7 +171,7 @@ def Translator(translations=None, policy=None):
``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.
+ :func:`translationstring.dugettext_policy` policy will be used.
The callable returned accepts three arguments: ``tstring``
(required), ``domain`` (optional) and ``mapping`` (optional).
@@ -225,8 +227,8 @@ def Pluralizer(translations=None, policy=None):
``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.
+ ``policy`` is ``None``, the
+ :func:`translationstring.dungettext_policy` policy will be used.
The object returned will be a callable which has the following
signature::
View
0 internatl/tests/__init__.py → translationstring/tests/__init__.py
File renamed without changes.
View
0 ...xtures/locales/de/LC_MESSAGES/messages.mo → ...xtures/locales/de/LC_MESSAGES/messages.mo
File renamed without changes.
View
0 ...xtures/locales/de/LC_MESSAGES/messages.po → ...xtures/locales/de/LC_MESSAGES/messages.po
File renamed without changes.
View
18 internatl/tests/test__init__.py → translationstring/tests/test__init__.py
@@ -2,7 +2,7 @@
class TestTranslationString(unittest.TestCase):
def _makeOne(self, msgid, **kw):
- from internatl import TranslationString
+ from translationstring import TranslationString
return TranslationString(msgid, **kw)
def test_is_unicode_subclass(self):
@@ -79,7 +79,7 @@ def test_interpolate_passed_translated(self):
class TestTranslationStringFactory(unittest.TestCase):
def _makeOne(self, domain):
- from internatl import TranslationStringFactory
+ from translationstring import TranslationStringFactory
return TranslationStringFactory(domain)
def test_allargs(self):
@@ -93,7 +93,7 @@ def test_allargs(self):
class TestChameleonTranslate(unittest.TestCase):
def _makeOne(self, translator):
- from internatl import ChameleonTranslate
+ from translationstring import ChameleonTranslate
return ChameleonTranslate(translator)
def test_msgid_nonstring(self):
@@ -131,7 +131,7 @@ def translator(msg):
class TestTranslator(unittest.TestCase):
def _makeOne(self, translations=None, policy=None):
- from internatl import Translator
+ from translationstring import Translator
return Translator(translations, policy)
def test_translations_None_interpolation_required(self):
@@ -183,7 +183,7 @@ def policy(translations, msg, domain):
class TestPluralizer(unittest.TestCase):
def _makeOne(self, translations=None, policy=None):
- from internatl import Pluralizer
+ from translationstring import Pluralizer
return Pluralizer(translations, policy)
def test_translations_None_interpolation_required(self):
@@ -207,7 +207,7 @@ def policy(translations, singular, plural, n, domain):
class Test_ugettext_policy(unittest.TestCase):
def _callFUT(self, translations, tstring, domain):
- from internatl import ugettext_policy
+ from translationstring import ugettext_policy
return ugettext_policy(translations, tstring, domain)
def test_it(self):
@@ -217,7 +217,7 @@ def test_it(self):
class Test_dugettext_policy(unittest.TestCase):
def _callFUT(self, translations, tstring, domain):
- from internatl import dugettext_policy
+ from translationstring import dugettext_policy
return dugettext_policy(translations, tstring, domain)
def test_it_use_default_domain(self):
@@ -258,7 +258,7 @@ def test_it_translations_has_no_dugettext(self):
class Test_ungettext_policy(unittest.TestCase):
def _callFUT(self, translations, singular, plural, n, domain=None,
mapping=None):
- from internatl import ungettext_policy
+ from translationstring import ungettext_policy
return ungettext_policy(translations, singular, plural, n, domain)
def test_it(self):
@@ -269,7 +269,7 @@ def test_it(self):
class Test_dungettext_policy(unittest.TestCase):
def _callFUT(self, translations, singular, plural, n, domain=None,
mapping=None):
- from internatl import dungettext_policy
+ from translationstring import dungettext_policy
return dungettext_policy(translations, singular, plural, n, domain)
def test_it_use_default_domain(self):
View
26 internatl/tests/test_integration.py → translationstring/tests/test_integration.py
@@ -10,9 +10,9 @@ def _makeTranslations(self):
def test_translator_ugettext_policy(self):
translations = self._makeTranslations()
- from internatl import Translator
- from internatl import ugettext_policy
- from internatl import TranslationString
+ from translationstring import Translator
+ from translationstring import ugettext_policy
+ from translationstring import TranslationString
translator = Translator(translations, ugettext_policy)
@@ -24,9 +24,9 @@ def test_translator_ugettext_policy(self):
def test_translator_dugettext_policy(self):
translations = self._makeTranslations()
- from internatl import Translator
- from internatl import dugettext_policy
- from internatl import TranslationString
+ from translationstring import Translator
+ from translationstring import dugettext_policy
+ from translationstring import TranslationString
translator = Translator(translations, dugettext_policy)
@@ -38,9 +38,9 @@ def test_translator_dugettext_policy(self):
def test_translator_with_interpolation(self):
translations = self._makeTranslations()
- from internatl import Translator
- from internatl import dugettext_policy
- from internatl import TranslationString
+ from translationstring import Translator
+ from translationstring import dugettext_policy
+ from translationstring import TranslationString
translator = Translator(translations, dugettext_policy)
@@ -59,8 +59,8 @@ def _makeTranslations(self):
def test_pluralizer_ungettext_policy(self):
translations = self._makeTranslations()
- from internatl import Pluralizer
- from internatl import ungettext_policy
+ from translationstring import Pluralizer
+ from translationstring import ungettext_policy
pluralizer = Pluralizer(translations, ungettext_policy)
@@ -73,8 +73,8 @@ def test_pluralizer_ungettext_policy(self):
def test_pluralizer_dungettext_policy(self):
translations = self._makeTranslations()
- from internatl import Pluralizer
- from internatl import dungettext_policy
+ from translationstring import Pluralizer
+ from translationstring import dungettext_policy
pluralizer = Pluralizer(translations, dungettext_policy)

0 comments on commit 753add8

Please sign in to comment.