Django internationalization minimal example

后端 未结 2 769
我寻月下人不归
我寻月下人不归 2020-12-05 01:38

I\'m having difficulty in internationalizing my app, so I present here a minimal example where my implementation fails.

Consider the following steps for producing a

2条回答
  •  天命终不由人
    2020-12-05 01:55

    Django collects translations in these 3 ways explained here: https://docs.djangoproject.com/en/dev/topics/i18n/translation/#how-django-discovers-translations

    The directories listed in LOCALE_PATHS have the highest precedence, with the ones appearing first having higher precedence than the ones appearing later.

    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.

    Finally, the Django-provided base translation in django/conf/locale is used as a fallback.

    Since your translation file is in none of these places you need to set it manually using LOCALE_PATHS as explained here: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-LOCALE_PATHS

提交回复
热议问题