我最近接手了一个包含locale文件夹的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文件并运行compilemessages时,一切正常。我似乎无法检测到新的字符串。什么想法可能导致问题?
非常感谢你。
答案 0 :(得分:0)
NVM人员,
我的settings.py文件中有一个错误:
以前的项目业主有以下内容:
LOCALE_PATHS = (
os.path.join(BASE_DIR +'/omefx/', 'locale'),
'locale',
)
我改为:
LOCALE_PATHS = (
os.path.join(BASE_DIR +'/omefx/', 'locale'),
)
现在可以使用了