Search code examples
pythonflaskjinja2python-babel

babel extract html does't work


<div>
    <table class="table" ng-hide="collapsed || filesVM.files.length == 0">
        <tr>
            <th>{{_('Filename')}}
                <small class="text-muted">({{ (filesVM.files | filter:fileSearch).length }} files)</small>
            </th>
        </tr>
    </table>
</div>

babel doesn't work, it cant extract the content, but it can work as below

<div>
    <table class="table" ng-hide="collapsed || filesVM.files.length == 0">
        <tr>
            <th>{{_('Filename')}}
                <small class="text-muted"></small>
            </th>
        </tr>
    </table>
</div>

with config

[jinja2: **/templates/**.html]
encoding = utf-8
extensions = jinja2.ext.autoescape, jinja2.ext.with_

how to change to make it work, and I'm not familiar with this field. Thanks a lot


Solution

  • Try to use tag gettext {{ gettext('your text') }} or maybe you forgot to set Jinja:

    JINJA_ENVIRONMENT = {
        'extensions': [
            'jinja2.ext.i18n'
       ]
    }