Мне нужно извлечь сообщения из файлов jinja2 из моего веб-приложения пирамиды, у Babel есть три метода извлечения по умолчанию (javascript, python, ignore). Как я могу добавить метод извлечения Jinja2?
Все мои пакеты обновлены (pyramid, setuptools, babel, jinja2).
Мой файл setup.py и файл setup.cfg находятся в одном каталоге, и я использовал python setup.py develop
на терминале, и произошла ошибка после успешного извлечения сообщения из файлов py, Ошибка => ValueError: Unknown extraction method 'jinja2'
:
# from distutils.core import setup
# # from babel.messages import frontend
from setuptools import setup
import setuptools
setuptools.dist.Distribution(dict(setup_requires='Babel')) # for message_extractors line below (else warnings / errors)
requires = [
'pyramid', 'peewee', 'configparser', 'khayyam', 'Babel',
'lingua', 'pyramid_redis_sessions', 'bcrypt', 'tornado', 'jinja2', 'pyramid-jinja2'
]
setup(name='Genetic',
install_requires=requires,
entry_points="""
[paste.app_factory]
main = Genetic:main
""",
author="Javad Asoodeh",
author_email="##",
message_extractors={'.': [
('Genetic/**.py', 'python', None),
('Genetic/**.jinja2', 'jinja2', {'input_encoding': 'utf-8'}),
('Genetic/template/base/**.jinja2', 'jinja2', {'input_encoding': 'utf-8'}),
('Genetic/templates/**.html', 'jinja2', {'input_encoding': 'utf-8'}),
('Genetic/templates/**.jinja2', 'jinja2', {'input_encoding': 'utf-8'}),
]},
)
Мой файл конфигурации Babel setup.cfg
:
[jinja2: **/templates/**.jinja2]
extensions=jinja2.ext.i18n
encoding = utf-8
[compile_catalog]
directory = Genetic/locale
domain = Genetic
statistics = true
[extract_messages]
add_comments = TRANSLATORS:
output_file = Genetic/locale/Genetic.pot
width = 80
input_dirs = Genetic/templates
[init_catalog]
domain = Genetic
input_file = Genetic/locale/Genetic.pot
output_dir = Genetic/locale
[update_catalog]
domain = Genetic
input_file = Genetic/locale/Genetic.pot
output_dir = Genetic/locale
previous = true