Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feature/add_action…
Browse files Browse the repository at this point in the history
…s_to_detail_view
  • Loading branch information
EdoStorm96 committed Jul 11, 2023
2 parents 2f108da + 6332e55 commit 2f59167
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 12 deletions.
64 changes: 64 additions & 0 deletions docs/developing/i18n.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,67 @@ Translations can be easily created using `python manage.py makemessages` and edi

.. _Anna Asbury: http://www.annaasbury.com/
.. _Poedit: https://poedit.net/


Merging translations
====================

Once messages have been generated with :code:`python manage.py makemessages -a`, you will often find that many line numbers and other fluff in your PO file have been changed, making any further changes very hard to merge back into the starting branch.

Before continuing, make all your changes to your feature branch and add all your translations. There's no point in merging translations multiple times, just do it once when the branch is ready to be merged.


Checking out both files
------------------

You should still be on the feature branch that you're preparing to merge back into a mainline branch, for this example we'll assume that branch is develop. We'll also assume your shell is in the directory containing django.po.

First, rename your django.po to feature.po::

mv django.po feature.po

Then, collect the django.po file you wish to merge into and rename it as well::

git checkout origin/develop -- django.po
mv django.po develop.po

The double dash (--) indicates that all arguments that follow are filenames. As such, this will only checkout the django.po file from develop.


Using msgcat
------------

The tool we will be using is called msgcat, which concatenates message files. Install it from your repositories if it's not already on your system.

In its most basic usage, msgcat will combine all messages from the input PO files and print them to standard output::

msgcat feature.po develop.po

We can redirect the standard output to a new file named django.po as follows::

msgcat feature.po develop.po > django.po

If you have only added new translations in your feature branch, this should be sufficient, and you now have a django.po which is sufficiently merged.

However, if you have also changed existing translations, you will end up with message sections like the following::

#: faqs/menus.py:26 feedback/models.py:20
#: feedback/templates/feedback/feedback_list.html:22
#: main/templates/base/menu.html:140
#, fuzzy
msgid "Feedback"
msgstr ""
"#-#-#-#-# feature.po #-#-#-#-#\n"
"Feedback duplicate\n"
"#-#-#-#-# develop.po #-#-#-#-#\n"
"Feedback"

This happens because the msgstr exists in both PO files but is not an exact match. To resolve such a situation, it is usually easy enough to use the search feature of your IDE to find these conflicts and resolve them manually in the same manner as for fuzzy translations.

Though msgcat can also help us in this situation. If we are careful to specify our feature.po file first, the following option will always choose the translation from feature.po above develop.po::

msgcat --use-first feature.po develop.po > django.po

This option is of course not possible if there are newer changes to translations in develop. These would be overwritten by the older translations in feature.po from when the feature branch branched off.

In the cases where both PO files contain changes you wish to keep, you can still manually select the correct translation from the output of msgcat. Although skillful use of msgat's :code:`--unique` and :code:`--more-than=1` options can save you the manual labour (see the manpage), the author's experience is that this rarely saves actual time spent on the merge.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions main/templates/main/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

{% block content %}
<div class="coverimage">
<img src="{% static 'main/images/coverimage-winter.jpg' %}" />
<img src="{% static 'main/images/coverimage-summer_Kim_Oleary.jpg' %}" />
</div>
<div class="uu-inner-container mt-1">
<div class="col-12">
Expand Down Expand Up @@ -190,7 +190,7 @@ <h6>
<hr> </hr>


<div class="col-12 mt-4"> <p>{% trans "Bannerfoto door Simona Evsatieva" %}</p></div>
<div class="col-12 mt-4"> <p>{% trans "Bannerfoto door Kim O'leary" %}</p></div>

</div>
{% endblock %}
2 changes: 1 addition & 1 deletion main/templates/registration/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
{% block content %}
{# TODO: when migration to SAML, this template needs to become a TemplateView #}
<div class="coverimage">
<img src="{% static 'main/images/coverimage-winter.jpg' %}" />
<img src="{% static 'main/images/coverimage-summer_Kim_Oleary.jpg' %}" />
</div>
{# Very ugly imitation of uu-hero #}
<div style="background: #FFCD00; margin: -10px -15px; padding:1rem;">
Expand Down
6 changes: 3 additions & 3 deletions proposals/fixtures/institutions.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"pk":1,
"fields":{
"order":4,
"description":"Utrecht instituut voor Linguistiek OTS (ILS)",
"description_nl":"Utrecht instituut voor Linguistiek OTS (ILS)",
"description_en":"Utrecht Institute of Linguistics OTS (ILS)",
"description":"Institute for Language Sciences Labs (ILS)",
"description_nl":"Institute for Language Sciences Labs (ILS)",
"description_en":"Institute for Language Sciences Labs (ILS)",
"reviewing_chamber":1
}
},
Expand Down
15 changes: 11 additions & 4 deletions proposals/templates/proposals/proposal_pdf_pre_approved.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,17 @@ <h2>{% trans "Algemene informatie over de aanvraag" %}</h2>
</tr>
{% if proposal.other_applicants %}
<tr>
<th>{% get_verbose_field_name "proposals" "proposal" "applicants" %}</th>
<td>{{ proposal.applicants.all|unordered_list }}</td>
</tr>
{% endif %}
<th>{% get_verbose_field_name "proposals" "proposal" "applicants" %}</th><td>
<ul>
{% for applicant in proposal.applicants.all %}
<li>
{{ applicant.get_full_name }}
</li>
{% endfor %}
</ul>
</td>
</tr>
{% endif %}
<tr>
<th>{% get_verbose_field_name "proposals" "proposal" "other_stakeholders" %}</th>
<td>{{ proposal.other_stakeholders|yesno:_("ja,nee") }}</td>
Expand Down
12 changes: 10 additions & 2 deletions proposals/templates/proposals/proposal_pdf_pre_assessment.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,17 @@ <h2>{% trans "Algemene informatie over de aanvraag" %}</h2>
</tr>
{% if proposal.other_applicants %}
<tr>
<th>{% get_verbose_field_name "proposals" "proposal" "applicants" %}</th><td>{{ proposal.applicants.all|unordered_list }}</td>
<th>{% get_verbose_field_name "proposals" "proposal" "applicants" %}</th><td>
<ul>
{% for applicant in proposal.applicants.all %}
<li>
{{ applicant.get_full_name }}
</li>
{% endfor %}
</ul>
</td>
</tr>
{% endif %}
{% endif %}
<tr>
<th>{% get_verbose_field_name "proposals" "proposal" "other_stakeholders" %}</th><td>{{ proposal.other_stakeholders|yesno:_("ja,nee") }}</td>
</tr>
Expand Down

0 comments on commit 2f59167

Please sign in to comment.