0

I need to extract messages from jinja2 files from my pyramid web app, Babel has a three default extraction method (javascript, python, ignore). How can i add Jinja2 extraction method ?

All my packages are updated (pyramid, setuptools, babel, jinja2).

My setup.py file and setup.cfg file are in same directory and i've used python setup.py develop on terminal and occurred an error after some successful message extraction from py files, The Error => 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'}),
      ]},
      )


My Babel configuration file 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
desertnaut
  • 57,590
  • 26
  • 140
  • 166
Javad Asoodeh
  • 299
  • 3
  • 12

1 Answers1

0

I fixed this error with reinstall Jinja2 library and babel library manually using pip package manager.

Javad Asoodeh
  • 299
  • 3
  • 12