python - Heroku 上的 Django 翻译无法完全正常工作

标签 python django heroku gettext

我在 Heroku 上部署了我的 Django 应用程序,并添加了 https://github.com/piotras/heroku-buildpack-gettext.git 这个 ugettext 构建包和应用程序的某些部分是注释翻译的。在本地运行正常,我不知道问题出在哪里。

例如,菜单项 Classes Types 未翻译,但其他部分已翻译。

{% trans "类类型"%}

模板

{% 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 "انواع الحلقات"

zh/LC_MESSAGES.po

#: templates/back_office/class_type_list.html:4
#: templates/back_office/menu.html:37
msgid "Class Types"
msgstr "Class Types"

最佳答案

经过一些研究,我发现将编译后的消息文件 (*.mo) 提交到 Heroku 会更好,这样翻译就可以正常工作了。

关于python - Heroku 上的 Django 翻译无法完全正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43743234/

相关文章:

Django 管理员 : Prefill data when clicking the add-another button next to a ForeignKey dropdown

python - 在 Python 中,尝试使用第二个 RESX 的内容更新 RESX

python - 使用 python Shutil 库移动文件

django - 未创建 uwsgi 套接字文件

python - RuntimeError:未指定表列/单元格宽度,无法继续

python - Heroku : request. 表单上的 Flask 在处理大量 POST 数据时速度非常慢?

mysql - 为什么 Heroku postgres 比本地 mysql 耗时更长?

ruby-on-rails - 使用 Clockwork 的计划作业和自定义时钟进程

python - 如何限制Qlineedit输入?

python - 如何通过 Python 在 Maya 中列出选定边上的顶点