django 18n:makemessages无法创建.po文件 [英] django 18n : makemessages does not create .po files
问题描述
我有一个django项目.
在这个项目中,有一个名为 core
I have a django project .
In this project,there is an app called core
我 cd核心
并尝试 python ../manage.py makemessages -l tw
但是它没有创建 django.po
文件,
我也尝试 django-admin.py makemessages -l tw
,但是有错误:
But it didn't create the django.po
file,
I also try django-admin.py makemessages -l tw
, but there is error:
Traceback (most recent call last):
File "/Users/winsome/env/bin/django-admin.py", line 5, in <module>
management.execute_from_command_line()
File "/Users/winsome/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/Users/winsome/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/winsome/env/lib/python2.7/site-packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Users/winsome/env/lib/python2.7/site-packages/django/core/management/base.py", line 338, in execute
output = self.handle(*args, **options)
File "/Users/winsome/env/lib/python2.7/site-packages/django/core/management/base.py", line 533, in handle
return self.handle_noargs(**options)
File "/Users/winsome/env/lib/python2.7/site-packages/django/core/management/commands/makemessages.py", line 283, in handle_noargs
potfiles = self.build_potfiles()
File "/Users/winsome/env/lib/python2.7/site-packages/django/core/management/commands/makemessages.py", line 299, in build_potfiles
file_list = self.find_files(".")
File "/Users/winsome/env/lib/python2.7/site-packages/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 "/Users/winsome/env/lib/python2.7/posixpath.py", line 327, in normpath
initial_slashes = path.startswith('/')
AttributeError: 'NoneType' object has no attribute 'startswith'
请帮助我,谢谢
settings.py
settings.py
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware', )
LANGUAGE_CODE = 'en-us'
USE_I18N = True
USE_L10N = True
LOCALE_PATHS = ( os.path.join(BASE_DIR, 'locale'), )
ugettext = lambda s: s
LANGUAGES = (
('en', ugettext('English')),
('tw', ugettext('Chinese')), )
TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')]
TEMPLATE_CONTEXT_PROCESSORS = ("django.core.context_processors.i18n",)
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATICFILES_DIRS = (
("js", os.path.join(STATIC_ROOT,'js')),
("css", os.path.join(STATIC_ROOT,'css')),
("img", os.path.join(STATIC_ROOT,'img')),
("video", os.path.join(STATIC_ROOT,'video')),
("file", os.path.join(STATIC_ROOT,'file')),
# ("fonts", os.path.join(STATIC_ROOT,'fonts')),
)
templates/english/index.html
templates/english/index.html
{% extends 'global/base.html' %}
{% load i18n %}
<ul id="header">
<li data-menuanchor="firstPage"><a href="{% url 'core:maininfo' %}#firstPage">{% trans "About" %}</a>
</li>
<li data-menuanchor="secondPage"><a href="{% url 'core:maininfo' %}#secondPage">{% trans "Features" %}</a>
</li>
<li data-menuanchor="3rdPage"><a href="{% url 'core:maininfo' %}#3rdPage">{% trans "Press" %}</a>
</li>
</ul>
推荐答案
您的问题与一个错误在Django 1.7中已得到修复.如果您使用git下载Django,则可以执行 git pull
.如果没有,请通过克隆开发版本或使用较旧的稳定Django版本重新安装Django.
Your problem is related to a bug in Django 1.7 that has already been fixed. If you downloaded Django using git, you can do a git pull
. If not re-install Django by cloning the development version or use an older stable Django version.
这篇关于django 18n:makemessages无法创建.po文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!