-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enabled makemessages to support several translation directories #1706
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1256,6 +1256,17 @@ is configured correctly). It creates (or updates) a message file in the | |
directory ``locale/LANG/LC_MESSAGES``. In the ``de`` example, the file will be | ||
``locale/de/LC_MESSAGES/django.po``. | ||
|
||
.. versionchanged:: 1.7 | ||
|
||
When you run ``makemessages`` from the root directory of your project, the | ||
extracted strings should be automatically distributed to the proper | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "should be" -> "will be" (or there a chance it won't work properly for some reason?) |
||
message files. That is, a string extracted from a file of an app containing | ||
a ``locale`` directory will go in a message file under that directory. | ||
A string extracted from a file of an app without any ``locale`` directory | ||
will either go in a message file under the directory listed first in | ||
:setting:`LOCALE_PATHS` or will generate an error if :setting:`LOCALE_PATHS` | ||
is empty. | ||
|
||
By default :djadmin:`django-admin.py makemessages <makemessages>` examines every | ||
file that has the ``.html`` or ``.txt`` file extension. In case you want to | ||
override that default, use the ``--extension`` or ``-e`` option to specify the | ||
|
@@ -1730,24 +1741,9 @@ 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. You only need to be in the same directory where the ``locale/`` directory | ||
is located. And you use :djadmin:`django-admin.py compilemessages <compilemessages>` | ||
tool. 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Sample project used by test_extraction.CustomLayoutExtractionTests | ||
from django.utils.translation import ugettext as _ | ||
|
||
string = _("This is a project-level string") |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.utils.translation import ugettext as _ | ||
|
||
string = _("This app has no locale directory") |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.utils.translation import ugettext as _ | ||
|
||
string = _("This app has a locale directory") |
Empty file.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.