pythondjangointernationalizationtranslationmakemessages

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


I have recently taken over a django project which contains a locale folder. Since then I have added many new {% blocktrans %} tags to the html files. However when I use the command:

python manage.py makemessages -l vi

to detect new tags, I get an error:

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'

BTW when I make modifications to the django.po file and run compilemessages everything works fine. I just can't seem to be able to detect new strings. Any Ideas what could be causing the issue?

Thank you very much in advance.


Solution

  • NVM folks,

    There was a mistake in my settings.py file:

    previous projects owners had the following:

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

    Which I changed to:

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

    and it works now