django - how to make translation work?

前端 未结 9 1090
不知归路
不知归路 2020-12-13 04:00

I\'m trying to render a template in a different language using i18n. I did everything I could read about, from setting the language code, creating and compiling translation

9条回答
  •  执笔经年
    2020-12-13 04:53

    Yes you do need to make message files as celopes suggests and then compile them

    python manage.py compilemessages
    

    But you will still have a problem.

    Disable LocaleMiddleware for a bit, i.e. remove this

    django.middleware.locale.LocaleMiddleware
    

    from your middleware list. Don't use it if you do not need to switch the language at run time, but if you do need it, then there is a solution. I had the same problem before and someone explained this to me.

    Also I had this weird issue before. Makemessages command would choke on strings wrapped with backslash in .py files.

提交回复
热议问题