我正在使用ugettext进行翻译,这很好,但我不知道发生了什么事情,当我在命令上写n="$(tail -1 abc.txt)" n="${n%${n#??}}"
时,它显示了很多错误:
django-admin makemessages
我在设置中仔细检查了这些行:
CommandError: errors happened while running msguniq
C:\Users\pouyasystem\Desktop\Project\BallBearingProject\BallbearingSite \locale\d
jango.pot:25:3: syntax error
C:\Users\pouyasystem\Desktop\Project\BallBearingProject\BallbearingSite\locale\d
jango.pot:25: keyword "models" unknown
C:\Users\pouyasystem\Desktop\Project\BallBearingProject\BallbearingSite\locale\d
jango.pot:25: keyword "py" unknown
C:\Users\pouyasystem\Desktop\Project\BallBearingProject\BallbearingSite\locale\d
jango.pot:25: keyword "models" unknown
C:\Users\pouyasystem\Desktop\Project\BallBearingProject\BallbearingSite\locale\d
jango.pot:25: keyword "py" unknown
C:\Users\pouyasystem\Desktop\Project\BallBearingProject\BallbearingSite\locale\d
jango.pot:42:3: syntax error
C:\Users\pouyasystem\Desktop\Project\BallBearingProject\BallbearingSite\locale\d
jango.pot:42: keyword "models" unknown
C:\Users\pouyasystem\Desktop\Project\BallBearingProject\BallbearingSite\locale\d
jango.pot:42: keyword "py" unknown
C:\Users\pouyasystem\Desktop\Project\BallBearingProject\BallbearingSite\locale\d
jango.pot:55:3: syntax error
C:\Users\pouyasystem\Desktop\Project\BallBearingProject\BallbearingSite\locale\d
jango.pot:55: keyword "models" unknown
C:\Users\pouyasystem\Desktop\Project\BallBearingProject\BallbearingSite\locale\d
jango.pot:55: keyword "py" unknown
C:\Users\pouyasystem\Desktop\Project\BallBearingProject\BallbearingSite\locale\d
jango.pot:60:3: syntax error
C:\Users\pouyasystem\Desktop\Project\BallBearingProject\BallbearingSite\locale\d
jango.pot:60: keyword "models" unknown
C:\Users\pouyasystem\Desktop\Project\BallBearingProject\BallbearingSite\locale\d
jango.pot:60: keyword "py" unknown
C:\Users\pouyasystem\Desktop\Project\BallBearingProject\BallbearingSite\locale\d
jango.pot:60: keyword "models" unknown
C:\Users\pouyasystem\Desktop\Project\BallBearingProject\BallbearingSite\locale\d
jango.pot:60: keyword "py" unknown
C:\Users\pouyasystem\Desktop\Project\BallBearingProject\BallbearingSite\locale\d
jango.pot:65:3: syntax error
C:\Users\pouyasystem\Desktop\Project\BallBearingProject\BallbearingSite\locale\d
jango.pot:65: keyword "models" unknown
C:\Users\pouyasystem\Desktop\Project\BallBearingProject\BallbearingSite\locale\d
jango.pot:65: keyword "py" unknown
C:\Users\pouyasystem\Desktop\Project\BallBearingProject\BallbearingSite\locale\d
jango.pot:70:3: syntax error
msguniq: too many errors, aborting
当STATIC_DIR=os.path.join(BASE_DIR,"static")
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
)
命令执行时,django.pot文件出现在“fa”文件夹(文件夹下的文件夹,最多为Lc_MESSAGES)但是在错误之后这个文件消失了,我想知道为什么它会尝试制作.POT文件夹在fa文件夹中,而不是在django.po和django.mo旁边的Lc_MESSAGES中?
当我手动将代码添加到django.po时,如:
django-admin makemessages
并执行django-admin compilemessages命令,翻译工作但makemessages无法正常工作
答案 0 :(得分:0)
在您的应用程序内创建一个文件夹,并将其命名为locale
,然后在locale
内创建另一个文件夹,并将其命名为fa
以使用PERSIAN语言。
之后,您的项目结构必须与以下相同:
- your_project
- your_app
- locale
- fa
manage.py
...
现在使用cd
命令并转到your_app
目录,然后使用django-admin makemessages
之后,您的项目结构必须与以下相同:
- your_project
- your_app
- locale
- fa
- LC_MESSAGES
django.po
manage.py
...