我试图在我的应用程序中添加翻译(本地化)图层。 我试图按照以下说明进行操作:https://docs.djangoproject.com/en/1.7/topics/i18n/translation/#how-to-create-language-files
但是当我试图运行
时,我遇到了一些问题django-admin.py makemessages -l he
为希伯来语创建翻译文件。
当我第一次运行此代码时,出现以下错误:
CommandError: Can't find msguniq. Make sure you have GNU gettext tools 0.15 or newer installed.
所以我运行命令:
brew install gettext
但我仍然有错误:
CommandError: Can't find msguniq. Make sure you have GNU gettext tools 0.15 or newer installed.
所以我在一些地方看到我需要跑:
brew link gettext --force
现在,当我尝试运行命令时:
django-admin.py makemessages -l he
我收到以下错误:
Traceback (most recent call last):
File "/usr/local/bin/django-admin.py", line 5, in <module>
pkg_resources.run_script('Django==1.7.1', 'django-admin.py')
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 492, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 1350, in run_script
execfile(script_filename, namespace, namespace)
File "/Library/Python/2.7/site-packages/Django-1.7.1-py2.7.egg/EGG-INFO/scripts/django-admin.py", line 5, in <module>
management.execute_from_command_line()
File "/Library/Python/2.7/site-packages/Django-1.7.1-py2.7.egg/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/Library/Python/2.7/site-packages/Django-1.7.1-py2.7.egg/django/core/management/__init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Python/2.7/site-packages/Django-1.7.1-py2.7.egg/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Library/Python/2.7/site-packages/Django-1.7.1-py2.7.egg/django/core/management/base.py", line 338, in execute
output = self.handle(*args, **options)
File "/Library/Python/2.7/site-packages/Django-1.7.1-py2.7.egg/django/core/management/base.py", line 533, in handle
return self.handle_noargs(**options)
File "/Library/Python/2.7/site-packages/Django-1.7.1-py2.7.egg/django/core/management/commands/makemessages.py", line 283, in handle_noargs
potfiles = self.build_potfiles()
File "/Library/Python/2.7/site-packages/Django-1.7.1-py2.7.egg/django/core/management/commands/makemessages.py", line 299, in build_potfiles
file_list = self.find_files(".")
File "/Library/Python/2.7/site-packages/Django-1.7.1-py2.7.egg/django/core/management/commands/makemessages.py", line 358, in find_files
ignored_roots = [os.path.normpath(p) for p in (settings.MEDIA_ROOT, settings.STATIC_ROOT)]
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/posixpath.py", line 327, in normpath
initial_slashes = path.startswith('/')
AttributeError: 'NoneType' object has no attribute 'starts with'
我正在使用带有Django 1.7和Python 2.7.6的Mac
请帮助理解我错过的内容
答案 0 :(得分:1)
您应该将django指向您项目的settings.py
文件。
export DJANGO_SETTINGS_MODULE=/path/to/settings.py
答案 1 :(得分:1)
尝试在您的应用中使用python ../manage.py makemessages -l en
django-admin.py
对我不起作用