Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

470
Visualizações
Django Translation on Heroku is not fully working

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" %}

template

{% 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>
....

ar/LC_MESSAGES.po

#: templates/back_office/class_type_list.html:4
#: templates/back_office/menu.html:37
msgid "Class Types"
msgstr "انواع الحلقات"

en/LC_MESSAGES.po

#: templates/back_office/class_type_list.html:4
#: templates/back_office/menu.html:37
msgid "Class Types"
msgstr "Class Types"
about 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

After some research, I found it's better to commit the compiled messages files (*.mo) to Heroku, and translation will work properly.

about 4 years ago · Santiago Trujillo Relatório

0

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.

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda