我是django和python中的新人。我的项目是在PyTools下为Visual Studio 2013创建的。 对于本地化,我创建' locale' manage.py级别的文件夹。我尝试运行以下命令:
。\ ClarisPyEnv \ Scripts \ python.exe manage.py makemessages -l he
我收到了错误:
Exception in thread Thread-2377:
Traceback (most recent call last):
File "C:\Python34\lib\threading.py", line 921, in _bootstrap_inner
self.run()
File "C:\Python34\lib\threading.py", line 869, in run
self._target(*self._args, **self._kwargs)
File "C:\Python34\lib\subprocess.py", line 1170, in _readerthread
buffer.append(fh.read())
File "C:\Python34\lib\encodings\cp1255.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 766: char
acter maps to <undefined>
Traceback (most recent call last):
File "manage.py", line 17, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\Alex\Documents\PythonProjects\ClarisPy\ClarisPy\ClarisPyEnv\lib
\site-packages\django\core\management\__init__.py", line 385, in execute_from_co
mmand_line
utility.execute()
File "C:\Users\Alex\Documents\PythonProjects\ClarisPy\ClarisPy\ClarisPyEnv\lib
\site-packages\django\core\management\__init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\Alex\Documents\PythonProjects\ClarisPy\ClarisPy\ClarisPyEnv\lib
\site-packages\django\core\management\base.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "C:\Users\Alex\Documents\PythonProjects\ClarisPy\ClarisPy\ClarisPyEnv\lib
\site-packages\django\core\management\base.py", line 338, in execute
output = self.handle(*args, **options)
File "C:\Users\Alex\Documents\PythonProjects\ClarisPy\ClarisPy\ClarisPyEnv\lib
\site-packages\django\core\management\base.py", line 533, in handle
return self.handle_noargs(**options)
File "C:\Users\Alex\Documents\PythonProjects\ClarisPy\ClarisPy\ClarisPyEnv\lib
\site-packages\django\core\management\commands\makemessages.py", line 290, in ha
ndle_noargs
self.write_po_file(potfile, locale)
File "C:\Users\Alex\Documents\PythonProjects\ClarisPy\ClarisPy\ClarisPyEnv\lib
\site-packages\django\core\management\commands\makemessages.py", line 402, in wr
ite_po_file
msgs, errors, status = popen_wrapper(args)
File "C:\Users\Alex\Documents\PythonProjects\ClarisPy\ClarisPy\ClarisPyEnv\lib
\site-packages\django\core\management\utils.py", line 25, in popen_wrapper
output, errors = p.communicate()
File "C:\Python34\lib\subprocess.py", line 959, in communicate
stdout, stderr = self._communicate(input, endtime, timeout)
File "C:\Python34\lib\subprocess.py", line 1234, in _communicate
stdout = stdout[0]
IndexError: list index out of range
这意味着什么?哪里有问题?请帮帮我!
感谢 亚历
答案 0 :(得分:0)
你不需要在python 3中指定unicode。 Unicode是默认值。
from django.utils.translation import ugettext as _
_('חתול')
足以使翻译和编码工作。