Ticket #14924: 14924.3.diff

File 14924.3.diff, 26.7 KB (added by Ramiro Morales, 14 years ago)

New patch: Removes count trickery in PendingDeprecationWarning code, expands documentation, adds release note blurbs.

  • django/utils/translation/__init__.py

    diff --git a/django/utils/translation/__init__.py b/django/utils/translation/__init__.py
    a b  
    11"""
    22Internationalization support.
    33"""
     4from os import path
     5import warnings
     6
    47from django.utils.encoding import force_unicode
    5 from django.utils.functional import lazy, curry
     8from django.utils.functional import lazy
     9from django.utils.importlib import import_module
    610
    711
    812__all__ = ['gettext', 'gettext_noop', 'gettext_lazy', 'ngettext',
     
    3337    performance effect, as access to the function goes the normal path,
    3438    instead of using __getattr__.
    3539    """
     40
    3641    def __getattr__(self, real_name):
    3742        from django.conf import settings
    3843        if settings.USE_I18N:
    3944            from django.utils.translation import trans_real as trans
     45
     46            if settings.SETTINGS_MODULE is not None:
     47                parts = settings.SETTINGS_MODULE.split('.')
     48                project = import_module(parts[0])
     49                if path.isdir(path.join(path.dirname(project.__file__), 'locale')):
     50                    warnings.warn(
     51                        "Translations in the project directory aren't supported anymore. Use the LOCALE_PATHS setting instead.",
     52                        PendingDeprecationWarning
     53                    )
     54
    4055        else:
    4156            from django.utils.translation import trans_null as trans
    4257        setattr(self, real_name, getattr(trans, real_name))
  • django/utils/translation/trans_real.py

    diff --git a/django/utils/translation/trans_real.py b/django/utils/translation/trans_real.py
    a b  
    125125
    126126        global _translations
    127127
    128         loc = to_locale(lang)
    129 
    130128        res = _translations.get(lang, None)
    131129        if res is not None:
    132130            return res
    133131
     132        loc = to_locale(lang)
     133
    134134        def _translation(path):
    135135            try:
    136136                t = gettext_module.translation('django', path, [loc], DjangoTranslation)
     
    159159                    res.merge(t)
    160160            return res
    161161
    162         for localepath in settings.LOCALE_PATHS:
    163             if os.path.isdir(localepath):
    164                 res = _merge(localepath)
    165 
    166         for appname in settings.INSTALLED_APPS:
     162        for appname in reversed(settings.INSTALLED_APPS):
    167163            app = import_module(appname)
    168164            apppath = os.path.join(os.path.dirname(app.__file__), 'locale')
    169165
     
    173169        if projectpath and os.path.isdir(projectpath):
    174170            res = _merge(projectpath)
    175171
     172        for localepath in reversed(settings.LOCALE_PATHS):
     173            if os.path.isdir(localepath):
     174                res = _merge(localepath)
     175
    176176        if res is None:
    177177            if fallback is not None:
    178178                res = fallback
  • django/views/i18n.py

    diff --git a/django/views/i18n.py b/django/views/i18n.py
    a b  
    196196    paths = []
    197197    en_selected = locale.startswith('en')
    198198    en_catalog_missing = True
    199     # first load all english languages files for defaults
     199    # paths of requested packages
    200200    for package in packages:
    201201        p = importlib.import_module(package)
    202202        path = os.path.join(os.path.dirname(p.__file__), 'locale')
    203203        paths.append(path)
     204    # add the filesystem paths listed in the LOCALE_PATHS setting
     205    paths.extend(list(reversed(settings.LOCALE_PATHS)))
     206    # first load all english languages files for defaults
     207    for path in paths:
    204208        try:
    205209            catalog = gettext_module.translation(domain, path, ['en'])
    206210            t.update(catalog._catalog)
     
    278282    src.append(LibFormatFoot)
    279283    src = ''.join(src)
    280284    return http.HttpResponse(src, 'text/javascript')
    281 
  • docs/howto/i18n.txt

    diff --git a/docs/howto/i18n.txt b/docs/howto/i18n.txt
    a b  
    44Using internationalization in your own projects
    55===============================================
    66
    7 At runtime, Django looks for translations by following this algorithm:
     7At runtime, Django builds an in-memory unified catalog of literals-translations.
     8To achieve this it looks for translations by following this algorithm regarding
     9the order in which it examines the different file paths to load the compiled
     10:term:`message files <message file>` (``.mo``) and the precedence of multiple
     11translations for the same literal:
    812
    9     * First, it looks for a ``locale`` directory in the directory containing
    10       your settings file.
    11     * Second, it looks for a ``locale`` directory in the project directory.
    12     * Third, it looks for a ``locale`` directory in each of the installed apps.
    13       It does this in the reverse order of INSTALLED_APPS
    14     * Finally, it checks the Django-provided base translation in
    15       ``django/conf/locale``.
     13    1. The directories listed in :setting:`LOCALE_PATHS` have the highest
     14       precedence, with the ones appearing first having higher precedence than
     15       the ones appearing later.
     16    2. Then, it looks for and uses if it exists a ``locale`` directory in each
     17       of the installed apps listed in :setting:`INSTALLED_APPS`.  The ones
     18       appearing first have higher precedence than the ones appearing later.
     19    3. Then, it looks for a ``locale`` directory in the project directory, or
     20       more accurately, in the directory containing your settings file.
     21    4. Finally, the Django-provided base translation in ``django/conf/locale``
     22       is used as a fallback.
     23
     24.. deprecated:: 1.3
     25    Lookup in the ``locale`` subdirectory of the directory containing your
     26    settings file (item 3 above) is deprecated since the 1.3 release and will be
     27    removed in Django 1.5. You can use the :setting:`LOCALE_PATHS` setting
     28    instead, by listing the absolute filesystem path of such ``locale``
     29    directory in the setting value.
     30
     31.. seealso::
     32
     33    The translations for literals included in JavaScript assets are looked up
     34    following a similar but not identical algorithm. See the
     35    :ref:`javascript_catalog view documentation <javascript_catalog-view>` for
     36    more details.
    1637
    1738In all cases the name of the directory containing the translation is expected to
    1839be named using :term:`locale name` notation. E.g. ``de``, ``pt_BR``, ``es_AR``,
     
    2041
    2142This way, you can write applications that include their own translations, and
    2243you can override base translations in your project path. Or, you can just build
    23 a big project out of several apps and put all translations into one big project
    24 message file. The choice is yours.
     44a big project out of several apps and put all translations into one big coomon
     45message file specific to the project you are composing. The choice is yours.
    2546
    2647.. note::
    2748
     
    3455
    3556All message file repositories are structured the same way. They are:
    3657
     58    * All paths listed in ``LOCALE_PATHS`` in your settings file are
     59      searched for ``<language>/LC_MESSAGES/django.(po|mo)``
     60    * ``$PROJECTPATH/locale/<language>/LC_MESSAGES/django.(po|mo)`` --
     61      deprecated, see above.
    3762    * ``$APPPATH/locale/<language>/LC_MESSAGES/django.(po|mo)``
    38     * ``$PROJECTPATH/locale/<language>/LC_MESSAGES/django.(po|mo)``
    39     * All paths listed in ``LOCALE_PATHS`` in your settings file are
    40       searched in that order for ``<language>/LC_MESSAGES/django.(po|mo)``
    4163    * ``$PYTHONPATH/django/conf/locale/<language>/LC_MESSAGES/django.(po|mo)``
    4264
    4365To create message files, you use the :djadmin:`django-admin.py makemessages <makemessages>`
     
    5072to make the compiler process all the directories in your :setting:`LOCALE_PATHS`
    5173setting.
    5274
    53 Application message files are a bit complicated to discover -- they need the
    54 :class:`~django.middleware.locale.LocaleMiddleware`. If you don't use the
    55 middleware, only the Django message files and project message files will be
    56 installed and available at runtime.
    57 
    5875Finally, you should give some thought to the structure of your translation
    5976files. If your applications need to be delivered to other users and will
    6077be used in other projects, you might want to use app-specific translations.
    61 But using app-specific translations and project translations could produce
    62 weird problems with ``makemessages``: It will traverse all directories below
    63 the current path and so might put message IDs into the project message file
    64 that are already in application message files.
     78But using app-specific translations and project-specific translations could
     79produce weird problems with ``makemessages``: It will traverse all directories
     80below the current path and so might put message IDs into a unified, common
     81message file for the current project that are already in application message
     82files.
    6583
    6684The easiest way out is to store applications that are not part of the project
    6785(and so carry their own translations) outside the project tree. That way,
    68 ``django-admin.py makemessages`` on the project level will only translate
     86``django-admin.py makemessages``, when ran on a project level will only extract
    6987strings that are connected to your explicit project and not strings that are
    7088distributed independently.
    7189
  • docs/ref/settings.txt

    diff --git a/docs/ref/settings.txt b/docs/ref/settings.txt
    a b  
    11491149A tuple of directories where Django looks for translation files.
    11501150See :ref:`using-translations-in-your-own-projects`.
    11511151
     1152Example::
     1153
     1154    LOCALE_PATHS = (
     1155        '/home/www/project/common_files/locale',
     1156        '/var/local/translations/locale'
     1157    )
     1158
     1159Note that in the paths you add to the value of this setting, if you have the
     1160typical ``/path/to/locale/xx/LC_MESSAGES`` hierarchy, you should use the path to
     1161the ``locale`` directory (i.e. ``'/path/to/locale'``).
     1162
    11521163.. setting:: LOGGING
    11531164
    11541165LOGGING
  • docs/releases/1.3.txt

    diff --git a/docs/releases/1.3.txt b/docs/releases/1.3.txt
    a b  
    454454<topics-testing-fixtures>`, or using the ``setUp()`` method of your
    455455test case.
    456456
     457Changed priority of translation loading
     458~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     459
     460Work has been done to homogeneize, simplify, rationalize and properly document
     461the algorithm used by Django at runtime to build translations from the
     462differents translations found on disk, namely:
     463
     464For translatable literals found in Python code and templates (``'django'``
     465gettext domain):
     466
     467 * Change the priority of the translations included with the applications
     468   listed in the :setting:`INSTALLED_APPS` setting. To provide a behavior
     469   consistent with other parts of Django that also use such setting
     470   (templates, etc.) now, when building the translation that will be made
     471   available, the apps listed first have higher precedence than the ones listed
     472   later.
     473
     474 * Provide a way to override the translations shipped with applications by using
     475   the :setting:`LOCALE_PATHS` setting whose translations have now higher
     476   precedence than the translations of ``INSTALLED_APPS`` applications.
     477   the relative priority among the values listed in this setting has also been
     478   modified so the paths listed first have higher precedence than the
     479   ones listed later.
     480
     481 * The ``locale`` subdirectory of the directory containing the settings, that
     482   usually coincides with and is know as the *project directory* is being
     483   deprecated in this release as a source of translations. (the precedence of
     484   these translations is intermediate between applications and ``LOCALE_PATHS``
     485   translations). See the `corresponding deprecated features section`_
     486   of this document.
     487
     488For translatable literals found in Javascript code (``'djangojs'`` gettext
     489domain):
     490
     491 * Similarly to the ``'django'`` domain translations: Allow overriding of
     492   translations shipped with applications by using the :setting:`LOCALE_PATHS`
     493   setting that is now used for this domain and whose translations have higher
     494   precedence than the translations of Python packages passed to the
     495   :ref:`javascript_catalog view <javascript_catalog-view>`.  Paths listed first
     496   have higher precedence than the ones listed later.
     497
     498 * Translations under the ``locale`` sbdirectory of the *project directory* have
     499   never been taken in account for JavaScript translations and remain in the
     500   same situation considering the deprecation of such location.
     501
     502.. _corresponding deprecated features section: loading_of_translations_from_the_project_directory_
     503
    457504.. _deprecated-features-1.3:
    458505
    459506Features deprecated in 1.3
     
    631678which was a bug-fix wrapper around the standard library ``SimpleCookie``. As the
    632679fixes are moving upstream, this is now deprecated - you should use ``from
    633680django.http import SimpleCookie`` instead.
     681
     682.. _loading_of_translations_from_the_project_directory:
     683
     684Loading of translations from the project directory
     685~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     686
     687This release of Django starts the deprecation process for inclusion of
     688translations located under the *project path* in the translation building
     689process performed at runtime. The :setting:`LOCALE_PATHS` setting can be used
     690for the same task by including in it the filesystem path to the ``locale``
     691directory containing project-level translations.
     692
     693Rationale for this decision:
     694
     695 * The *project path* has always been a loosely defined concept (actually, the
     696   directory used for locating project-level translations is the directory
     697   containing the settings module) and there has been a shift in other parts
     698   of the framework to stop using it as a reference for location of assets at
     699   runtime.
     700
     701 * Detection of the ``locale`` subdirectory tends to fail when the deployment
     702   scenario is more complex than the basic one. e.g. it fails when the settings
     703   module is a directory (ticket #10765).
     704
     705 * Potential for strange development- and deployment-time problems like the
     706   fact that the ``project_dir/locale/`` subdir can generate spurious error
     707   messages when the project directory is included in the Python path (default
     708   behavior of ``manage.py runserver``) and then it clashes with the equally
     709   named standard library module::
     710
     711     /usr/lib/python2.6/gettext.py:49: ImportWarning: Not importing directory '/path/to/project/dir/locale': missing __init__.py.
     712     import locale, copy, os, re, struct, sys
     713
     714 * This location hadn't never been included so far in the translation building
     715   process for JavaScript literals.
  • docs/topics/i18n/deployment.txt

    diff --git a/docs/topics/i18n/deployment.txt b/docs/topics/i18n/deployment.txt
    a b  
    171171How Django discovers translations
    172172---------------------------------
    173173
    174 As described in :ref:`using-translations-in-your-own-projects`,
    175 at runtime, Django looks for translations by following this algorithm:
     174As described in :ref:`using-translations-in-your-own-projects`, Django looks for
     175translations by following this algorithm regarding the order in which it
     176examines the different file paths to load the compiled :term:`message files
     177<message file>` (``.mo``) and the precedence of multiple translations for the
     178same literal:
    176179
    177     * First, it looks for a ``locale`` directory in the directory containing
    178       your settings file.
    179     * Second, it looks for a ``locale`` directory in the project directory.
    180     * Third, it looks for a ``locale`` directory in each of the installed apps.
    181       It does this in the reverse order of INSTALLED_APPS
    182     * Finally, it checks the Django-provided base translation in
    183       ``django/conf/locale``.
     180    1. The directories listed in :setting:`LOCALE_PATHS` have the highest
     181       precedence, with the ones appearing first having higher precedence than
     182       the ones appearing later.
     183    2. Then, it looks for and uses if it exists a ``locale`` directory in each
     184       of the installed apps listed in :setting:`INSTALLED_APPS`.  The ones
     185       appearing first have higher precedence than the ones appearing later.
     186    3. Then, it looks for a ``locale`` directory in the project directory, or
     187       more accurately, in the directory containing your settings file.
     188    4. Finally, the Django-provided base translation in ``django/conf/locale``
     189       is used as a fallback.
     190
     191.. deprecated:: 1.3
     192    Lookup in the ``locale`` subdirectory of the directory containing your
     193    settings file (item 3 above) is deprecated since the 1.3 release and will be
     194    removed in Django 1.5. You can use the :setting:`LOCALE_PATHS` setting
     195    instead, by listing the absolute filesystem path of such ``locale``
     196    directory in the setting value.
     197
     198.. seealso::
     199
     200    The translations for literals included in JavaScript assets are looked up
     201    following a similar but not identical algorithm. See the
     202    :ref:`javascript_catalog view documentation <javascript_catalog-view>` for
     203    more details.
    184204
    185205In all cases the name of the directory containing the translation is expected to
    186206be named using :term:`locale name` notation. E.g. ``de``, ``pt_BR``, ``es_AR``,
  • docs/topics/i18n/internationalization.txt

    diff --git a/docs/topics/i18n/internationalization.txt b/docs/topics/i18n/internationalization.txt
    a b  
    348348Working with lazy translation objects
    349349-------------------------------------
    350350
    351 .. highlightlang:: python
    352 
    353351Using ``ugettext_lazy()`` and ``ungettext_lazy()`` to mark strings in models
    354352and utility functions is a common operation. When you're working with these
    355353objects elsewhere in your code, you should ensure that you don't accidentally
     
    633631Specifying translation strings: In JavaScript code
    634632==================================================
    635633
     634.. highlightlang:: python
     635
    636636Adding translations to JavaScript poses some problems:
    637637
    638638    * JavaScript code doesn't have access to a ``gettext`` implementation.
     
    647647translations into JavaScript, so you can call ``gettext``, etc., from within
    648648JavaScript.
    649649
     650.. _javascript_catalog-view:
     651
    650652The ``javascript_catalog`` view
    651653-------------------------------
    652654
     
    657659The main solution to these problems is the :meth:`django.views.i18n.javascript_catalog`
    658660view, which sends out a JavaScript code library with functions that mimic the
    659661``gettext`` interface, plus an array of translation strings. Those translation
    660 strings are taken from the application, project or Django core, according to what
    661 you specify in either the info_dict or the URL.
     662strings are taken from applications or Django core, according to what you
     663specify in either the info_dict or the URL. Paths listed in
     664:setting:`LOCALE_PATHS` are also included.
    662665
    663666You hook it up like this::
    664667
     
    676679those catalogs are merged into one catalog. This is useful if you have
    677680JavaScript that uses strings from different applications.
    678681
     682The precedence of translations is such that the packages appearing later in the
     683``packages`` argument have higher precedence than the ones appearing at the
     684beginning, this is important in the case of clashing translations for the same
     685literal.
     686
    679687By default, the view uses the ``djangojs`` gettext domain. This can be
    680688changed by altering the ``domain`` argument.
    681689
     
    691699catalog file. As a security measure, these values can only be either
    692700``django.conf`` or any package from the :setting:`INSTALLED_APPS` setting.
    693701
     702The JavaScript translations found in the paths listed in the
     703:setting:`LOCALE_PATHS` setting are also always included. To keep consistency
     704with the translations lookup order algorithm used for Python and templates, the
     705directories listed in :setting:`LOCALE_PATHS` have the highest precedence with
     706the ones appearing first having higher precedence than the ones appearing
     707later.
     708
     709.. versionchanged:: 1.3
     710    Directories listed in ``LOCALE_PATHS`` weren't included in the lookup
     711    algorithm until version 1.3.
     712
    694713Using the JavaScript translation catalog
    695714----------------------------------------
    696715
    697 To use the catalog, just pull in the dynamically generated script like this::
     716.. highlightlang:: javascript
     717
     718To use the catalog, just pull in the dynamically generated script like this:
     719
     720.. code-block:: html+django
    698721
    699722    <script type="text/javascript" src="{% url django.views.i18n.javascript_catalog %}"></script>
    700723
     
    751774The ``set_language`` redirect view
    752775==================================
    753776
     777.. highlightlang:: python
     778
    754779.. function:: set_language(request)
    755780
    756781As a convenience, Django comes with a view, :meth:`django.views.i18n.set_language`,
  • tests/regressiontests/i18n/other/locale/de/LC_MESSAGES/django.po

    diff --git a/tests/regressiontests/i18n/other/locale/de/LC_MESSAGES/django.po b/tests/regressiontests/i18n/other/locale/de/LC_MESSAGES/django.po
    a b  
    88"Project-Id-Version: django tests\n"
    99"Report-Msgid-Bugs-To: \n"
    1010"POT-Creation-Date: 2010-02-14 17:33+0100\n"
    11 "PO-Revision-Date: 2011-01-16 17:14+0100\n"
     11"PO-Revision-Date: 2011-01-21 21:37-0300\n"
    1212"Last-Translator: Jannis Leidel <jannis@leidel.info>\n"
    1313"Language-Team: de <de@li.org>\n"
    1414"MIME-Version: 1.0\n"
     
    1818
    1919#: models.py:3
    2020msgid "Time"
    21 msgstr "Time (LOCALE_PATHS)"
     21msgstr "Zeit (LOCALE_PATHS)"
    2222
    2323#: models.py:5
     24msgid "Date/time"
     25msgstr "Datum/Zeit (LOCALE_PATHS)"
     26
     27#: models.py:7
    2428msgctxt "month name"
    2529msgid "May"
    2630msgstr "Mai"
    2731
    28 #: models.py:7
     32#: models.py:9
    2933msgctxt "verb"
    3034msgid "May"
    3135msgstr "Kann"
    3236
    33 #: models.py:9
     37#: models.py:11
    3438msgctxt "search"
    3539msgid "%d result"
    3640msgid_plural "%d results"
    3741msgstr[0] "%d Resultat"
    3842msgstr[1] "%d Resultate"
    39 
  • tests/regressiontests/i18n/resolution/locale/de/LC_MESSAGES/django.po

    diff --git a/tests/regressiontests/i18n/resolution/locale/de/LC_MESSAGES/django.po b/tests/regressiontests/i18n/resolution/locale/de/LC_MESSAGES/django.po
    a b  
    99"Project-Id-Version: PACKAGE VERSION\n"
    1010"Report-Msgid-Bugs-To: \n"
    1111"POT-Creation-Date: 2010-02-14 17:33+0100\n"
    12 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
     12"PO-Revision-Date: 2011-01-21 21:37-0300\n"
    1313"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
    1414"Language-Team: LANGUAGE <LL@li.org>\n"
    1515"MIME-Version: 1.0\n"
     
    1818"Plural-Forms: nplurals=2; plural=(n != 1)\n"
    1919
    2020#: models.py:3
     21msgid "Time"
     22msgstr "Zeit (APP)"
     23
     24#: models.py:5
    2125msgid "Date/time"
    2226msgstr "Datum/Zeit (APP)"
  • tests/regressiontests/i18n/tests.py

    diff --git a/tests/regressiontests/i18n/tests.py b/tests/regressiontests/i18n/tests.py
    a b  
    660660
    661661    def assertUgettext(self, msgid, msgstr):
    662662        result = ugettext(msgid)
    663         self.assert_(msgstr in result, ("The string '%s' isn't in the "
     663        self.assertTrue(msgstr in result, ("The string '%s' isn't in the "
    664664            "translation of '%s'; the actual result is '%s'." % (msgstr, msgid, result)))
    665665
    666666class AppResolutionOrderI18NTests(ResolutionOrderI18NTests):
    667667
    668668    def setUp(self):
    669669        self.old_installed_apps = settings.INSTALLED_APPS
    670         settings.INSTALLED_APPS = list(settings.INSTALLED_APPS) + ['regressiontests.i18n.resolution']
     670        settings.INSTALLED_APPS = ['regressiontests.i18n.resolution'] + list(settings.INSTALLED_APPS)
    671671        super(AppResolutionOrderI18NTests, self).setUp()
    672672
    673673    def tearDown(self):
     
    691691    def test_locale_paths_translation(self):
    692692        self.assertUgettext('Time', 'LOCALE_PATHS')
    693693
     694    def test_locale_paths_override_app_translation(self):
     695        old_installed_apps = settings.INSTALLED_APPS
     696        settings.INSTALLED_APPS = list(settings.INSTALLED_APPS) + ['regressiontests.i18n.resolution']
     697        try:
     698            self.assertUgettext('Time', 'LOCALE_PATHS')
     699        finally:
     700            settings.INSTALLED_APPS = old_installed_apps
     701
     702    def test_locale_paths_override_project_translation(self):
     703        old_settings_module = settings.SETTINGS_MODULE
     704        settings.SETTINGS_MODULE = 'regressiontests'
     705        try:
     706            self.assertUgettext('Date/time', 'LOCALE_PATHS')
     707        finally:
     708            settings.SETTINGS_MODULE = old_settings_module
     709
    694710class ProjectResolutionOrderI18NTests(ResolutionOrderI18NTests):
    695711
    696712    def setUp(self):
     
    708724    def test_project_override_app_translation(self):
    709725        old_installed_apps = settings.INSTALLED_APPS
    710726        settings.INSTALLED_APPS = list(settings.INSTALLED_APPS) + ['regressiontests.i18n.resolution']
    711         self.assertUgettext('Date/time', 'PROJECT')
    712         settings.INSTALLED_APPS = old_installed_apps
    713 
    714     def test_project_override_locale_paths_translation(self):
    715         old_locale_paths = settings.LOCALE_PATHS
    716         settings.LOCALE_PATHS += (os.path.join(os.path.dirname(os.path.abspath(__file__)), 'other', 'locale'),)
    717         self.assertUgettext('Date/time', 'PROJECT')
    718         settings.LOCALE_PATHS = old_locale_paths
     727        try:
     728            self.assertUgettext('Date/time', 'PROJECT')
     729        finally:
     730            settings.INSTALLED_APPS = old_installed_apps
    719731
    720732class DjangoFallbackResolutionOrderI18NTests(ResolutionOrderI18NTests):
    721733
    722734    def test_django_fallback(self):
    723         self.assertUgettext('Date/time', 'Datum/Zeit')
     735        self.assertEqual(ugettext('Date/time'), 'Datum/Zeit')
    724736
    725737
    726738class TestModels(TestCase):
  • tests/regressiontests/locale/de/LC_MESSAGES/django.po

    diff --git a/tests/regressiontests/locale/de/LC_MESSAGES/django.po b/tests/regressiontests/locale/de/LC_MESSAGES/django.po
    a b  
    99"Project-Id-Version: PACKAGE VERSION\n"
    1010"Report-Msgid-Bugs-To: \n"
    1111"POT-Creation-Date: 2010-02-14 17:33+0100\n"
    12 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
     12"PO-Revision-Date: 2011-01-21 21:37-0300\n"
    1313"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
    1414"Language-Team: LANGUAGE <LL@li.org>\n"
    1515"MIME-Version: 1.0\n"
     
    1818"Plural-Forms: nplurals=2; plural=(n != 1)\n"
    1919
    2020#: models.py:3
     21msgid "Time"
     22msgstr "Zeit (PROJECT)"
     23
     24#: models.py:5
    2125msgid "Date/time"
    2226msgstr "Datum/Zeit (PROJECT)"
  • tests/regressiontests/views/tests/i18n.py

    diff --git a/tests/regressiontests/views/tests/i18n.py b/tests/regressiontests/views/tests/i18n.py
    a b  
    11# -*- coding:utf-8 -*-
    22import gettext
     3from os import path
    34
    45from django.conf import settings
    56from django.test import TestCase
     
    150151        response = self.client.get('/views/jsi18n_multi_packages2/')
    151152        self.assertContains(response, javascript_quote('este texto de app3 debe ser traducido'))
    152153        deactivate()
     154
     155    def testI18NWithLocalePaths(self):
     156        settings.LANGUAGE_CODE = 'es-ar'
     157        self.old_locale_paths = settings.LOCALE_PATHS
     158        settings.LOCALE_PATHS += (path.join(path.dirname(path.dirname(path.abspath(__file__))), 'app3', 'locale'),)
     159        response = self.client.get('/views/jsi18n/')
     160        self.assertContains(response, javascript_quote('este texto de app3 debe ser traducido'))
     161        settings.LOCALE_PATHS = self.old_locale_paths
Back to Top