Reputation: 3297
I deployed my Django app on Heroku and I added https://github.com/piotras/heroku-buildpack-gettext.git
this ugettext buildpack and some parts of the application are note translated. Locally it's working, I don't know where is the issue coming from.
For example, the menu item Classes Types is not translated but other parts are.
{% trans "Class Types" %}
{% load i18n %}
....
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{% trans "Class Types" %}<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>
<a href="{% url 'class_type-list' %}">
<span class="glyphicon glyphicon-list" aria-hidden="true"></span> {% trans "All" %}</a>
</li>
<li>
<a href="{% url 'class_type-new' %}">
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span> {% trans "New" %}</a>
</li>
</ul>
</li>
....
#: templates/back_office/class_type_list.html:4
#: templates/back_office/menu.html:37
msgid "Class Types"
msgstr "انواع الحلقات"
#: templates/back_office/class_type_list.html:4
#: templates/back_office/menu.html:37
msgid "Class Types"
msgstr "Class Types"
Upvotes: 3
Views: 504
Reputation: 2800
You can generate those files during the build.
Add a post compile file in bin/post_compile
(no extension like procfile) with the following line:
python manage.py compilemessages
Optionally you can add the specific language (e.g. python manage.py compilemessages -l nl
)
Since Heroku 20, gettext is automatically added for the default Python build package. This is only during build and not at runtime. Therefore the command should be added in post_compile
and not under release:
in the procfile
.
Older info links to buildpacks for gettext
on Heroku (e.g. in the question above). Those are not needed anymore with this configuration.
Upvotes: 3
Reputation: 3297
After some research, I found it's better to commit the compiled messages files (*.mo) to Heroku, and translation will work properly.
Upvotes: 3