i18n doesn't work at production environment on heroku

前端 未结 7 1506
陌清茗
陌清茗 2021-01-05 02:30

I have seen more than one hundred posts about i18n issues and no solution seems to solve my problem.

I have an app running with Django 1.3.1 and it works Fine at my

7条回答
  •  时光取名叫无心
    2021-01-05 02:37

    In the sample above you wrote LC_MESAGES instead of LC_MESSAGES (notice the double S), I believe this very well could be your issue.

    If not then read on!

    I had this issue (again!) recently, and the answer was found in this part of the django documentation

    I suspect you have the same issue since your "admin" app was translated but not your own (project) app.

    It seems that Django is looking for your translations like so:

    1. The directories listed in LOCALE_PATHS have the highest precedence, with the ones appearing first having higher precedence than the ones appearing later.
    2. Then, it looks for and uses if it exists a locale directory in each of the installed apps listed in INSTALLED_APPS. The ones appearing first have higher precedence than the ones appearing later.
    3. Finally, the Django-provided base translation in django/conf/locale is used as a fallback.

    With the settings you described above, you must make sure your tree looks something like this (with the most important being settings.py is in the dir above the 'locale' dir):

    +-project_top/
      |
      +-project_app/
      | |
      | +-locale/
      | | |
      | | +-pt_BR/
      | |   |
      | |   +-LC_MESSAGES/
      | |     |
      | |     +-django.po
      | |  
      | +-settings.py
      |
      +-manage.py
    

提交回复
热议问题