Home>
The following message will be displayed in django standard when the password is changed.

msgstr ""
"Please enter the correct% (username) s and password. Both fields are uppercase"
"Is case sensitive."


https://github.com/django/django/blob/master/django/contrib/auth/locale/en/LC_MESSAGES/django.po

I don't want to modify the po file directly as django will be updated in the future.
For example, when I want to change your password to "Not correct your password" when you enter the wrong password
not django/django/contrib/auth/locale/ja/LC_MESSAGES/django.po
Which file should I put the code in?

  • Answer # 1

    If you put a locale file in your project as follows and write a translation corresponding to the English text you want to replace, you can overwrite the standard text.

    project_root
      └locale
        └─ja
            └─LC_MESSAGES
                  django.mo
                  django.po
                  djangojs.mo
                  djangojs.po

    That's the example question.
    project_root/locale/en/LC_MESSAGES/django.po

    msgid ""
    msgid ""
    "Project-Id-Version: django \ n"
    "Report-Msgid-Bugs-To: \ n"
    "POT-Creation-Date: 2019-12-02 16: 49 + 0100 \ n"
    "PO-Revision-Date: 2019-12-02 16: 41 + 0000 \ n"
    "Last-Translator: example\ n"
    "Language-Team: Japanese (http://www.transifex.com/django/django/language/"
    "ja /) \ n"
    "MIME-Version: 1.0 \ n"
    "Content-Type: text/plain;charset = UTF-8 \ n"
    "Content-Transfer-Encoding: 8bit \ n"
    "Language: en \ n"
    "Plural-Forms: nplurals = 1;plural = 0;\ n"
    msgid ""
    "Please enter a correct% (username) s and password. Note that both fields may"
    "be case-sensitive."
    msgid ""
    "Your password is incorrect"

    The English text of msgid can be found by searching for the corresponding Japanese text in the Django source code.

    In order to reflect the contents of the above file, it is necessary not only to place the file but also to rewrite and compile the configuration file. Please refer here for those procedures.
    [Python] Add Django locale file to change Japanese message-Qiita