Skip to content

Commit

Permalink
Reorganized locale directories and added Transifex config for managin…
Browse files Browse the repository at this point in the history
…g the translation process (#866)
  • Loading branch information
tobiasmcnulty committed Mar 12, 2019
1 parent 0a6cf5c commit 68ecaee
Show file tree
Hide file tree
Showing 20 changed files with 792 additions and 205 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
__pycache__
*.pyc
*.db
docs/locale/*/LC_MESSAGES/django.mo
locale/*/LC_MESSAGES/django.mo
*/locale/*/LC_MESSAGES/django.mo
.sass-cache/
.coverage
.tox
Expand Down
23 changes: 23 additions & 0 deletions .tx/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[main]
host = https://www.transifex.com
type = PO

# Get translations for the 'docs' app from the 'django-docs' project (resource: 'website-strings')
[django-docs.website-strings]
file_filter = docs/locale/<lang>/LC_MESSAGES/django.po
source_file = docs/locale/en/LC_MESSAGES/django.po
source_lang = en

# Get translations for the 'dashboard' app from the 'djangoproject.com' project (resource: 'dashboard-app')
# 'dashboard' is a reserved word in Transifex, so we use 'dashboard-app' instead.
[djangoproject-com.dashboard-app]
file_filter = dashboard/locale/<lang>/LC_MESSAGES/django.po
source_file = dashboard/locale/en/LC_MESSAGES/django.po
source_lang = en

# Send everything else to the 'main' resource in the 'djangoproject.com' project.
# If/when needed, other apps may be split out into separate resources (a la 'dashboard' above).
[djangoproject-com.main]
file_filter = locale/<lang>/LC_MESSAGES/django.po
source_file = locale/en/LC_MESSAGES/django.po
source_lang = en
84 changes: 84 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -287,3 +287,87 @@ from a copy of the production database and saved to the
To update this file, run::

./manage.py dumpdata dashboard --exclude dashboard.Datum --indent=4 > dashboard_production_metrics.json

Translation
-----------

We're using Transifex to help manage the translation process. The
``requirements/dev.txt`` file will install the Transifex client.

Before using the command-line Transifex client, create ``~/.transifexrc``
according to the instructions at
https://docs.transifex.com/client/client-configuration. You'll need to be a
member of the Django team in the `Django
<https://www.transifex.com/django/>`_ organization at Transifex. For
information on how to join, please see the `Translations
<https://docs.djangoproject.com/en/dev/internals/contributing/localizing/#translations>`_
section of the documentation on contributing to and localizing Django.

Since this repo hosts three separate sites, our ``.po`` files are organized by
website domain. At the moment, we have:

* ``dashboard/locale/`` contains the translation files for
https://dashboard.djangoproject.com
* ``docs/locale/`` contains the translation files for
https://docs.djangoproject.com (only for the strings in this repository;
translation of the documentation itself is handled elsewhere)
* ``locale/`` contains the translation files for https://www.djangoproject.com
(including strings from all apps other than ``dashboard`` and ``docs``)

**Important:** To keep this working properly, note that any templates for the
``dashboard`` and ``docs`` apps **must** be placed in the
``<app name>/templates/docs/`` directory for their respective app, **not** in
the ``djangoproject/templates/`` directory.

Updating messages on Transifex
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

When there are changes to the messages in the code or templates, a member of
the translations team will need to update Transifex as follows:

1. Regenerate the English (only) .po file::

python manage.py makemessages -l en

(Never update alternate language .po files using makemessages. We'll update
the English file, upload it to Transifex, then later pull the .po files with
translations down from Transifex.)

2. Push the updated source file to Transifex::

tx push -s

3. Commit and push the changes to github::

git commit -m "Updated messages" locale/en/LC_MESSAGES/*
git push

Updating translations from Transifex
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Anytime translations on Transifex have been updated, someone should update
our translation files as follows:

1. Review the translations in Transifex and add to the space-delimited
``LANGUAGES`` list in ``update-translations.sh`` any new languages that have
reached 100% translation.

2. Pull the updated translation files::

./update-translations.sh

3. Use ``git diff`` to see if any translations have actually changed. If not,
you can just revert the .po file changes and stop here.

4. Compile the messages::

python manage.py compilemessages

5. Run the test suite one more time::

python manage.py test

6. Commit and push the changes to GitHub::

git commit -m "Updated translations" locale/*/LC_MESSAGES/*
git push
23 changes: 23 additions & 0 deletions dashboard/locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright (C) Django Software Foundation and contributors
# This file is distributed under the same license as the djangoproject.com
# source files.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-02-18 20:21-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#: dashboard/templates/dashboard/index.html:22
#, python-format
msgid "Updated %(timestamp)s ago."
msgstr ""
25 changes: 25 additions & 0 deletions dashboard/locale/fr/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (C) Django Software Foundation and contributors
# This file is distributed under the same license as the djangoproject.com
# source files.
#
# Translators:
# Tobias McNulty <tobias+dsf@caktusgroup.com>, 2019
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-02-18 20:21-0500\n"
"PO-Revision-Date: 2019-02-21 14:15+0000\n"
"Last-Translator: Tobias McNulty <tobias+dsf@caktusgroup.com>, 2019\n"
"Language-Team: French (https://www.transifex.com/django/teams/17080/fr/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: fr\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"

#, python-format
msgid "Updated %(timestamp)s ago."
msgstr "Mis à jour il y a %(timestamp)s."
File renamed without changes.
File renamed without changes.

0 comments on commit 68ecaee

Please sign in to comment.