I18n stopped working

别说谁变了你拦得住时间么 提交于 2019-12-04 06:24:54

Just set STATIC_ROOT in your settings.py file.

This is a bug in Django 1.7.1 and should be removed in Django 1.7.2

(Since Django 1.6.2 STATIC_ROOT defaults to None, before ''.)

Had the same issue after upgrading to Django 1.7

I fixed it by specifying the settings module each time I run django-admin.py:

cd ~/myproject/myproject # where the ``locale`` folder exists
PYTHONPATH=~/myproject django-admin.py makemessages --settings=myproject.settings -l <language>

Update: It is a bug fixed in Django 1.7.2 see: https://docs.djangoproject.com/en/1.7/releases/1.7.2/ https://code.djangoproject.com/ticket/23717

first Define your local path for makemessages

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

In terminal

$python manage.py makemessages -l pl

go the folder and open the file edit the .po file

Then in terminal

$python manage.py compilemessages

it works fine in Django 1.7 and upgraded too.

i think it may help you.

Problem is when You didn't setup your STATIC_ROOT and MEDIA_ROOT settings value. After setting this like:

MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
STATIC_ROOT = os.path.join(BASE_DIR, 'static')

I'm using make_messages.sh script:

#!/usr/bin/env bash

for dir in `find -maxdepth 1 -type d ! -iname ".*"`; do
    echo $dir
    tmp=$(basename $dir)
    dir="$tmp"
    skip_this=0
    for tmp in static media; do
        if [ "$dir" = "$tmp" ]; then
            skip_this=1
            break
        fi
    done

    if [ "$skip_this" = "1" ]; then
        echo Skipping $dir
        continue
    fi

    cd `dirname $0`/$dir
    if [ ! -d locale ] ; then
        echo Creating 'locale' directory
        mkdir locale
    fi
    ../manage.py makemessages -l pl -l en -l de
        cd ..
done

and after executing make_messages.sh:

./static_page
processing locale pl
processing locale en
processing locale de
./common
Creating locale directory
processing locale pl
processing locale en
processing locale de

And this is my compile_messages.sh script:

#!/usr/bin/env bash

for dir in `find -maxdepth 1 -type d ! -iname ".*"`; do
        echo $dir
        tmp=$(basename $dir)
        dir="$tmp"
        skip_this=0
        for tmp in static static_custom media; do
                if [ "$dir" = "$tmp" ]; then
                        skip_this=1
                        break
                fi
        done

        if [ "$skip_this" = "1" ]; then
                echo Skipping $dir
                continue
        fi

        cd `dirname $0`/$dir
        ../manage.py compilemessages -l pl -l en -l de
        cd ..
done

I had the same problems using Django 1.7.1.

I fixed it by changing the command: django-admin.py to python manage.py.

So my entire command goes like this:

python manage.py makemessages --locale=en --ignore=templates/admin --ignore=project/settings.py

Jan Rudolf

I had the same ussue. I tried to run with django-admin, and got this issue.

When I run it with manage.py, it runs ok.

python manage_local.py makemessages -l cs --settings=gprojects.settings_local

Use manage.py, manage_local.py is my alternated version.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!