django translation template {% trans “something” %}

前端 未结 4 1570
你的背包
你的背包 2021-01-05 00:29

Ok I have been searching like crazy for this I think simple problem.

I use Django 1.4

The problem is that django won\'t translate a simple {% trans \"work\"

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-05 01:14

    The position you key the command matter.

    In my case, this is my project structure:

    myproject/
        manage.py
        mysite/
            __init__.py
            settings.py
            urls.py
            wsgi.py
        apps/
            migrations/
            __init__.py
            admin.py
            models.py
            tests.py
            views.py
    

    If I call makemessages at mysite folder, like this:

    D:\...\myproject\mysite> python ../manage.py makemessages -all
    

    it will not get the string in HTML {% trans "str" %}.
    But if I call makemessages at myproject folder, like this:

    D:\...\myproject> python manage.py makemessages -all
    

    it works! It finds all {% trans "str" %} in HTML.
    So be careful about the location you are.

提交回复
热议问题