Django 翻译:找不到 msguniq
Django translation: can't find msguniq
我想在 Django 应用程序中进行翻译。
我正在关注 this tutorial 但我 运行 遇到了问题。
我运行代码后
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',
]
有谁知道会出什么问题吗?
您是否尝试过不带引号的命令?
python manage.py makemessages -l de
检查您是否可以 运行 msguniq
手动:
$ msguniq --help
如果出现命令未找到错误,请确保为 brew 正确设置了 PATH
环境变量。
您是否尝试过使用 django-admin:
django-admin makemessages -l de
你有符号链接吗?
brew link gettext --force
此外,当我在 brew 上安装它时,还有一些额外的步骤。你做到了吗?
- 我正在更新 .zshrc,但是如果你使用 bash,它会是,比方说,.bashrc
如果您需要在您的 PATH 运行 中首先安装此软件:
echo 'export PATH="/usr/local/opt/gettext/bin:$PATH"' >> ~/.zshrc
要让编译器找到此软件,您可能需要设置:
LDFLAGS:-L/usr/local/opt/gettext/lib
CPPFLAGS:-I/usr/local/opt/gettext/include
export LDFLAGS=-L/usr/local/opt/gettext/lib
export CPPFLAGS=-I/usr/local/opt/gettext/include
我想在 Django 应用程序中进行翻译。
我正在关注 this tutorial 但我 运行 遇到了问题。
我运行代码后
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',
]
有谁知道会出什么问题吗?
您是否尝试过不带引号的命令?
python manage.py makemessages -l de
检查您是否可以 运行 msguniq
手动:
$ msguniq --help
如果出现命令未找到错误,请确保为 brew 正确设置了 PATH
环境变量。
您是否尝试过使用 django-admin:
django-admin makemessages -l de
你有符号链接吗?
brew link gettext --force
此外,当我在 brew 上安装它时,还有一些额外的步骤。你做到了吗?
- 我正在更新 .zshrc,但是如果你使用 bash,它会是,比方说,.bashrc
如果您需要在您的 PATH 运行 中首先安装此软件:
echo 'export PATH="/usr/local/opt/gettext/bin:$PATH"' >> ~/.zshrc
要让编译器找到此软件,您可能需要设置:
LDFLAGS:-L/usr/local/opt/gettext/lib
CPPFLAGS:-I/usr/local/opt/gettext/include
export LDFLAGS=-L/usr/local/opt/gettext/lib
export CPPFLAGS=-I/usr/local/opt/gettext/include