Django的翻译:找不到msguniq(Django translation: can't

2019-10-31 06:27发布

我想里面做Django应用翻译。

我跟随本教程 ,但我遇到的问题。

当我运行代码

python manage.py makemessages -l 'de'

我得到的错误

CommandError: Can't find msguniq. Make sure you have GNU gettext tools 0.15 or newer installed.

奇怪的是,我已经安装了gettext

Warning: gettext 0.19.8.1 is already installed and up-to-date
To reinstall 0.19.8.1, run `brew reinstall gettext`

我已经设定的设置:

# Translations
# Provide a lists of languages which your site supports.
LANGUAGES = (
    ('en', _('English')),
    ('de', _('German')),
)
# Set the default language for your site.
LANGUAGE_CODE = 'en'
# Tell Django where the project's translation files should be.
LOCALE_PATHS = (
    os.path.join(BASE_DIR, 'locale'),
)
print(LOCALE_PATHS)

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.locale.LocaleMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

难道有谁知道什么会错呢?

Answer 1:

您是否尝试过使用Django管理员:

django-admin makemessages -l de

你们有符号链接?

brew link gettext --force

此外,当我安装了它在酿造,有一些额外的步骤。 你做的?

  • 我更新.zshrc,但如果你使用bash,这将是,说的.bashrc

如果您需要先有这样的软件在您的PATH运行: echo 'export PATH="/usr/local/opt/gettext/bin:$PATH"' >> ~/.zshrc

对于编译器找到这个软件,你可能需要设置:LDFLAGS:-L在/ usr /本地的/ opt / gettext的/ lib目录CPPFLAGS:-I在/ usr /本地的/ opt / gettext的/包括export LDFLAGS=-L/usr/local/opt/gettext/lib export CPPFLAGS=-I/usr/local/opt/gettext/include



Answer 2:

你有没有尝试过的命令,而没有围绕语言引号?

python manage.py makemessages -l de

Django的makemessages



Answer 3:

请检查您是否可以运行msguniq手动:

$ msguniq --help

如果给你一个命令没有发现错误,请确保您的PATH环境变量设置正确冲泡。



文章来源: Django translation: can't find msguniq