标签: makemessages

Django makemessages“struct.error:解包需要 4 个字节的缓冲区”

我有一个 django 实例打包在 docker-compose 中的 Docker 容器中。

我正在尝试为项目生成 makemessages 文件,但是当我尝试运行 makemessages 时,这就是我收到的响应

root@6fc510c9c5d1:/code# python manage.py makemessages
/usr/local/lib/python3.6/dist-packages/daphne/server.py:12: UserWarning: Something has already installed a non-asyncio Twisted reactor. Attempting to uninstall it; you can fix this warning by importing daphne.server early in your codebase or finding the package that imports Twisted and importing it later on.
  UserWarning,
Traceback (most recent call last):
  File "manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.6/dist-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.6/dist-packages/django/core/management/__init__.py", line 347, in execute …
Run Code Online (Sandbox Code Playgroud)

python django gettext docker makemessages

7
推荐指数
1
解决办法
4129
查看次数

makemessages 命令导致 html.py 文件和 UnicodeDecodeError

当我运行此命令时:

django-admin makemessages -l ar
Run Code Online (Sandbox Code Playgroud)

它给出了这个错误:

Traceback (most recent call last):
File "c:\users\ahmed\appdata\local\programs\python\python36-32\lib\site-packages\django\utils\encoding.py", line 65, in force_text
s = str(s, encoding, errors)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9 in position 3107: invalid continuation byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\users\ahmed\appdata\local\programs\python\python36-32\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\users\ahmed\appdata\local\programs\python\python36-32\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\Ahmed\AppData\Local\Programs\Python\Python36-32\Scripts\django-admin.exe\__main__.py", line 9, in <module>
File "c:\users\ahmed\appdata\local\programs\python\python36-32\lib\site- packages\django\core\management\__init__.py", line 371, in execute_from_command_line
utility.execute()
File …
Run Code Online (Sandbox Code Playgroud)

python django localization internationalization makemessages

6
推荐指数
1
解决办法
843
查看次数

django-admin makemessages --no-obsolete似乎不起作用

首先,我期待--no-obsolete会注释掉msgid,msgstr如果gettext被删除,对吧?

我的测试方法是:

  1. gettext("some string here")在视野中 写道
  2. 我跑了makemessages命令
  3. .po按预期编写了一个文件
  4. 然后我gettext()从视图中删除了行并保存了文件,验证了runserver工作.
  5. 我跑了makemessages --no-obsolete,它没有对.po文件进行任何更改.

.po 文件内容提取.

#. Translators: This message is a test of wrap line
#: servers/views.py:31
msgid "Do let me know if it works."
msgstr ""
Run Code Online (Sandbox Code Playgroud)

开发环境

Django = 1.11
OS = Mac/Ubuntu 14.04

settings.py

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = …
Run Code Online (Sandbox Code Playgroud)

django django-admin django-management-command makemessages

5
推荐指数
1
解决办法
672
查看次数

如何通过在Django 2.0中创建语言文件来集成多语言支持?

我想创建一个由Django 2.0支持的网站(包括自动生成的管理网站),该网站应支持多种语言。

现在,我只想保留两种语言,英语阿拉伯语

我在网上阅读了许多教程文章,以使用django-admin的makemessagescompilemessages命令生成语言文件(.po文件)和编译.mo文件(由makemessages命令生成)。

但是我没有获得有关使用Django2.0进行此集成的任何特定解决方案,但我仍然面临这个问题。

谁能帮我解决这个问题。

并建议如何将英语翻译阿拉伯语

translation arabic python-3.x makemessages django-2.0

1
推荐指数
1
解决办法
2348
查看次数