Kaydet (Commit) ce27fb19 authored tarafından Ramiro Morales's avatar Ramiro Morales

Revert "Patch by Claude for #16084."

This reverts commit 2babab0b.
üst 5b99d5a3
......@@ -193,8 +193,7 @@ Ignore files or directories matching this glob-style pattern. Use multiple
times to ignore more (makemessages command).
.TP
.I \-\-no\-default\-ignore
Don't ignore the common private glob-style patterns 'CVS', '.*', '*~' and '*.pyc'
(makemessages command).
Don't ignore the common private glob-style patterns 'CVS', '.*' and '*~' (makemessages command).
.TP
.I \-\-no\-wrap
Don't break long message lines into several lines (makemessages command).
......
......@@ -472,7 +472,7 @@ Example usage::
Use the ``--ignore`` or ``-i`` option to ignore files or directories matching
the given :mod:`glob`-style pattern. Use multiple times to ignore more.
These patterns are used by default: ``'CVS'``, ``'.*'``, ``'*~'``, ``'*.pyc'``
These patterns are used by default: ``'CVS'``, ``'.*'``, ``'*~'``
Example usage::
......@@ -499,7 +499,7 @@ for technically skilled translators to understand each message's context.
.. versionadded:: 1.6
Use the ``--keep-pot`` option to prevent django from deleting the temporary
.pot files it generates before creating the .po file. This is useful for
.pot file it generates before creating the .po file. This is useful for
debugging errors which may prevent the final language files from being created.
runfcgi [options]
......
......@@ -1543,9 +1543,24 @@ All message file repositories are structured the same way. They are:
* ``$PYTHONPATH/django/conf/locale/<language>/LC_MESSAGES/django.(po|mo)``
To create message files, you use the :djadmin:`django-admin.py makemessages <makemessages>`
tool. And you use :djadmin:`django-admin.py compilemessages <compilemessages>`
tool. You only need to be in the same directory where the ``locale/`` directory
is located. And you use :djadmin:`django-admin.py compilemessages <compilemessages>`
to produce the binary ``.mo`` files that are used by ``gettext``.
You can also run :djadmin:`django-admin.py compilemessages
--settings=path.to.settings <compilemessages>` to make the compiler process all
the directories in your :setting:`LOCALE_PATHS` setting.
Finally, you should give some thought to the structure of your translation
files. If your applications need to be delivered to other users and will be used
in other projects, you might want to use app-specific translations. But using
app-specific translations and project-specific translations could produce weird
problems with :djadmin:`makemessages`: it will traverse all directories below
the current path and so might put message IDs into a unified, common message
file for the current project that are already in application message files.
The easiest way out is to store applications that are not part of the project
(and so carry their own translations) outside the project tree. That way,
:djadmin:`django-admin.py makemessages <makemessages>`, when ran on a project
level will only extract strings that are connected to your explicit project and
not strings that are distributed independently.
......@@ -5,13 +5,10 @@ import os
import re
import shutil
from django.conf import settings
from django.core import management
from django.test import SimpleTestCase
from django.test.utils import override_settings
from django.utils.encoding import force_text
from django.utils._os import upath
from django.utils import six
from django.utils.six import StringIO
......@@ -355,44 +352,3 @@ class MultipleLocaleExtractionTests(ExtractorTests):
management.call_command('makemessages', locale='pt,de,ch', verbosity=0)
self.assertTrue(os.path.exists(self.PO_FILE_PT))
self.assertTrue(os.path.exists(self.PO_FILE_DE))
class CustomLayoutExtractionTests(ExtractorTests):
def setUp(self):
self._cwd = os.getcwd()
self.test_dir = os.path.join(os.path.dirname(upath(__file__)), 'project_dir')
def test_no_locale_raises(self):
os.chdir(self.test_dir)
with six.assertRaisesRegex(self, management.CommandError,
"Unable to find a locale path to store translations for file"):
management.call_command('makemessages', locale=LOCALE, verbosity=0)
@override_settings(
LOCALE_PATHS=(os.path.join(os.path.dirname(upath(__file__)), 'project_dir/project_locale'),)
)
def test_project_locale_paths(self):
"""
Test that:
* translations for app containing locale folder are stored in that folder
* translations outside of that app are in LOCALE_PATHS[0]
"""
os.chdir(self.test_dir)
self.addCleanup(shutil.rmtree, os.path.join(settings.LOCALE_PATHS[0], LOCALE))
self.addCleanup(shutil.rmtree, os.path.join(self.test_dir, 'app_with_locale/locale', LOCALE))
management.call_command('makemessages', locale=LOCALE, verbosity=0)
project_de_locale = os.path.join(
self.test_dir, 'project_locale/de/LC_MESSAGES/django.po',)
app_de_locale = os.path.join(
self.test_dir, 'app_with_locale/locale/de/LC_MESSAGES/django.po',)
self.assertTrue(os.path.exists(project_de_locale))
self.assertTrue(os.path.exists(app_de_locale))
with open(project_de_locale, 'r') as fp:
po_contents = force_text(fp.read())
self.assertMsgId('This app has no locale directory', po_contents)
self.assertMsgId('This is a project-level string', po_contents)
with open(app_de_locale, 'r') as fp:
po_contents = force_text(fp.read())
self.assertMsgId('This app has a locale directory', po_contents)
from django.utils.translation import ugettext as _
string = _("This is a project-level string")
from django.utils.translation import ugettext as _
string = _("This app has no locale directory")
from django.utils.translation import ugettext as _
string = _("This app has a locale directory")
......@@ -33,7 +33,7 @@ if can_run_extraction_tests:
JavascriptExtractorTests, IgnoredExtractorTests, SymlinkExtractorTests,
CopyPluralFormsExtractorTests, NoWrapExtractorTests,
NoLocationExtractorTests, KeepPotFileExtractorTests,
MultipleLocaleExtractionTests, CustomLayoutExtractionTests)
MultipleLocaleExtractionTests)
if can_run_compilation_tests:
from .commands.compilation import (PoFileTests, PoFileContentsTests,
PercentRenderingTests, MultipleLocaleCompilationTests)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment