Django + Heroku:编译消息有效,但我的翻译文件无效. [英] Django+Heroku: compilemessages works but not MY translation file.

查看:48
本文介绍了Django + Heroku:编译消息有效,但我的翻译文件无效.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现自己处于非常奇怪的状况:

I find myself in a very weird situation:

  1. 我没有将我的 .mo 文件提交到我的仓库中.我计划在部署后生成它们
  2. 我在 https://github.com/piotras/heroku-buildpack-gettext.git
  3. 上安装了gettext buildpack.
  1. I do not have my .mo files committed into my repo. I plan to generate them after I deploy
  2. I installed the gettext buildpack availabe at https://github.com/piotras/heroku-buildpack-gettext.git

这就是我要做的步骤:

  1. 部署到heroku.
  2. 运行 heroku运行python manage,py compilemessages
  3. 正在输出:

  1. Deploy to heroku.
  2. Run heroku run python manage,py compilemessages
  3. This is being outputted:

在/app/.heroku/python/lib/python3.6/site-packages/django/contrib/redirects/locale/ru/LC/MESSAGES

processing file django.po in /app/.heroku/python/lib/python3.6/site-packages/django/contrib/redirects/locale/ru/LC_MESSAGES

在/app/.heroku/python/lib/python3.6/site-packages/django/contrib/redirects/locale/cy/LC_MESSAGES

processing file django.po in /app/.heroku/python/lib/python3.6/site-packages/django/contrib/redirects/locale/cy/LC_MESSAGES

处理/app/prometheus/locale/zh_hans/LC_MESSAGES中的文件django.po

processing file django.po in /app/prometheus/locale/zh_hans/LC_MESSAGES

处理文件django.po

processing file django.po in /app/.heroku/python/lib/python3.6/site-packages/django/contrib/gis/locale/sk/LC_MESSAGES

列出文件之一: heroku run ls/app/.heroku/python/lib/python3.6/site-packages/django/contrib/redirects/locale/zh_Hans/LC_MESSAGES 结果: django.mo django.po

List one of files: heroku run ls /app/.heroku/python/lib/python3.6/site-packages/django/contrib/redirects/locale/zh_Hans/LC_MESSAGES RESULTS: django.mo django.po

列出我们的文件: heroku run ls/app/prometheus/locale/zh_hans/LC_MESSAGES/结果: django.po

List our file: heroku run ls /app/prometheus/locale/zh_hans/LC_MESSAGES/ RESULTS: django.po

django.mo丢失.

我运行了 python manage.py shell 来查看我是否有一些错误的变量:

django.mo is missing.

I ran python manage.py shell to see if I have some variables wrong:

heroku run python manage.py shell
In [1]: from django from django.conf import settings
In [3]: print(settings.BASE_DIR)
/app/prometheus
In [4]: print(settings.LOCALE_PATHS)
('/app/prometheus/locale',)

所以我不知道为什么我的django.mo文件没有生成.

So i have no idea why my django.mo file is not being generated.

有没有猜到?

推荐答案

TL; DR:先生成Django.mo,然后将其删除.

TL;DR: Django.mo is generated and then deleted.

我处于相同的情况,并尝试使用

I'm in the same situation and tried to generate the files with

$ heroku run django-admin compilemessages
$ heroku run ls locale/LANG/LC_MESSAGES/
django.po

我不想等待每个命令都使用Heroku并使用

I didn't want to wait for connecting to Heroku on every command and used

$ heroku run "django-admin compilemessages; ls locale/LANG/LC_MESSAGES/"
django.mo django.po
$ heroku run ls locale/LANG/LC_MESSAGES/
django.po

结果是,创建了django.mo,但是由于某种原因,它立即被删除.

Turns out, django.mo is created but for some reason it is immediately deleted.

使用谷歌搜索功能可为Heroku帮助页面为什么我的文件上传丢失/删除了吗?:

Googling this gives Heroku Help -page Why are my file uploads missing/deleted?:

Heroku文件系统是短暂的-这意味着在dyno运行时,对文件系统的任何更改只会持续到dyno关闭或重新启动为止.每个dyno都会使用最新部署中的文件系统的干净副本进行引导.

The Heroku filesystem is ephemeral - that means that any changes to the filesystem whilst the dyno is running only last until that dyno is shut down or restarted. Each dyno boots with a clean copy of the filesystem from the most recent deploy.

会发生什么

heroku run COMMAND

启动一个新的dyno,在其中运行命令,并在命令退出后关闭dyno,因此删除了该命令创建的所有文件.

starts a new dyno, runs the command in it and shuts down the dyno once the command has exited, so all the files the command created are deleted.

据我所知,可以选择提交.mo文件进行回购,也可以从存储中提供它们,例如S3 .

As far as I know, options are either to commit the .mo-files to repo or serve them from storage, for example S3.

这篇关于Django + Heroku:编译消息有效,但我的翻译文件无效.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆