我想在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',
]
有谁知道会出现什么问题?
答案 0 :(得分:0)
答案 1 :(得分:0)
检查您是否可以手动运行$ msguniq --help
:
PATH
如果这样可以找到命令未找到错误,请确保为brew设置了let index = [{"Name":"Aish Merahrah","Origin":"Egypt","Description":"Made with fenugreek seeds and maize; dough allowed to ferment overnight, then flattened and baked."},{"Name":"Ajdov Kruh","Origin":"Slovenia","Description":"Made with buckwheat flour and potato."}];
let lat = {"Slovenia": "46.151241, 14.995463", "Egypt": "26.820553, 30.802498"};
index.forEach(o => o.Origin = lat[o.Origin] ? lat[o.Origin] : o.Origin);
console.log(index);
环境变量。
答案 2 :(得分:0)
您是否尝试过使用django-admin:
django-admin makemessages -l de
您有没有符号链接?
brew link gettext --force
此外,当我将其安装在brew上时,还有一些额外的步骤。你做了那些吗?
如果您需要首先在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