Django 翻译问题:makemessages 命令未检测到新的 {% blocktrans %} 标签

Django Translation Issue: makemessages command not detecting new {% blocktrans %} tags

我最近接手了一个包含语言环境文件夹的 Django 项目。从那时起,我在 html 文件中添加了许多新的 {% blocktrans %} 标签。但是当我使用命令时:

python manage.py makemessages -l vi

检测新标签时,出现错误:

Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/Brigadier90/Projects/RoyalExc/myvenv/lib/python3.6/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
    utility.execute()
  File "/Users/Brigadier90/Projects/RoyalExc/myvenv/lib/python3.6/site-packages/django/core/management/__init__.py", line 359, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/Brigadier90/Projects/RoyalExc/myvenv/lib/python3.6/site-packages/django/core/management/base.py", line 294, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Users/Brigadier90/Projects/RoyalExc/myvenv/lib/python3.6/site-packages/django/core/management/base.py", line 345, in execute
    output = self.handle(*args, **options)
  File "/Users/Brigadier90/Projects/RoyalExc/myvenv/lib/python3.6/site-packages/django/core/management/commands/makemessages.py", line 361, in handle
    potfiles = self.build_potfiles()
  File "/Users/Brigadier90/Projects/RoyalExc/myvenv/lib/python3.6/site-packages/django/core/management/commands/makemessages.py", line 393, in build_potfiles
    self.process_files(file_list)
  File "/Users/Brigadier90/Projects/RoyalExc/myvenv/lib/python3.6/site-packages/django/core/management/commands/makemessages.py", line 488, in process_files
    self.process_locale_dir(locale_dir, files)
  File "/Users/Brigadier90/Projects/RoyalExc/myvenv/lib/python3.6/site-packages/django/core/management/commands/makemessages.py", line 580, in process_locale_dir
    write_pot_file(potfile, msgs)
  File "/Users/Brigadier90/Projects/RoyalExc/myvenv/lib/python3.6/site-packages/django/core/management/commands/makemessages.py", line 191, in write_pot_file
    with io.open(potfile, 'a', encoding='utf-8') as fp:
FileNotFoundError: [Errno 2] No such file or directory: 'locale/django.pot'
(myvenv) Brigadier90s-MacBook-Pro:royalexc Brigadier90$ python manage.py makemessages -l vi
Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/Brigadier90/Projects/RoyalExc/myvenv/lib/python3.6/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
    utility.execute()
  File "/Users/Brigadier90/Projects/RoyalExc/myvenv/lib/python3.6/site-packages/django/core/management/__init__.py", line 359, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/Brigadier90/Projects/RoyalExc/myvenv/lib/python3.6/site-packages/django/core/management/base.py", line 294, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Users/Brigadier90/Projects/RoyalExc/myvenv/lib/python3.6/site-packages/django/core/management/base.py", line 345, in execute
    output = self.handle(*args, **options)
  File "/Users/Brigadier90/Projects/RoyalExc/myvenv/lib/python3.6/site-packages/django/core/management/commands/makemessages.py", line 361, in handle
    potfiles = self.build_potfiles()
  File "/Users/Brigadier90/Projects/RoyalExc/myvenv/lib/python3.6/site-packages/django/core/management/commands/makemessages.py", line 393, in build_potfiles
    self.process_files(file_list)
  File "/Users/Brigadier90/Projects/RoyalExc/myvenv/lib/python3.6/site-packages/django/core/management/commands/makemessages.py", line 488, in process_files
    self.process_locale_dir(locale_dir, files)
  File "/Users/Brigadier90/Projects/RoyalExc/myvenv/lib/python3.6/site-packages/django/core/management/commands/makemessages.py", line 580, in process_locale_dir
    write_pot_file(potfile, msgs)
  File "/Users/Brigadier90/Projects/RoyalExc/myvenv/lib/python3.6/site-packages/django/core/management/commands/makemessages.py", line 191, in write_pot_file
    with io.open(potfile, 'a', encoding='utf-8') as fp:
FileNotFoundError: [Errno 2] No such file or directory: 'locale/django.pot'

顺便说一句,当我修改 django.po 文件和 运行 编译消息时,一切正常。我似乎无法检测到新字符串。任何可能导致问题的想法?

非常感谢您。

NVM 伙计们,

我的 settings.py 文件中有一个错误:

以前的项目所有者有以下内容:

LOCALE_PATHS = (
    os.path.join(BASE_DIR +'/omefx/', 'locale'),
    'locale',
)

我改成了:

LOCALE_PATHS = (
        os.path.join(BASE_DIR +'/omefx/', 'locale'),
    )

现在可以使用了