Django 18n: makemessages doesn't create .po files

I have a django project.
This project has an app calledcore

I cd core

and trypython ../manage.py makemessages -l tw

But it didn't create the file django.po

,
I also try django-admin.py makemessages -l tw

, but there is an 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' 

      

Please help me, thanks.

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

{% 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>

      

0


source to share


1 answer


Your problem is due to a bug in Django 1.7 that has already been fixed. If you downloaded Django with git you can do git pull

. Unless you reinstall Django by cloning the development version, or use the old version of Django, the old version.



0


source







All Articles