Password MinimumLengthValidator

I am running a custom fork based on Maple.3 and I have encountered a problem with translation on the registration page.

The minimum password length error message is not translated to the language that is chosen.

Is anyone else encountering this issue?

It’s very common to stumble upon untranslated strings. Given the fact that not all targeted langagues are 100% translated . Also I just checked the Chinese langauge on transfiex open edx project its about ~65% translated as of today.

Lastly, if you translate the string NOW in transfiex it will be applied in Oilve. otherwise you need may be to follow i18n guildline of tutor to manually add the missing translation and then rebuild the image.

The problem is that there is no string to translate. MinimumLengthValidator function I mentioned does not use any string that can be translated.

There is only the at least x characters part of the error message and there is no match to “This password is short” in the Django.po files.

Yes I can confirm that I coudln’t see any string for “This password is short” I am not 100% sure yet. I specualte that is the default error message of HTML. Are using a spesfic theme? Also it would be useful if you can print the HTML content of password input field, so we can see if there is an error message for min length. It can for the min error the message is undefiend, thus it failback to default HTML

This string is from Django: django.contrib.auth.password_validation | Django documentation | Django

[docs]class MinimumLengthValidator:
    """
    Validate whether the password is of a minimum length.
    """
    def __init__(self, min_length=8):
        self.min_length = min_length

    def validate(self, password, user=None):
        if len(password) < self.min_length:
            raise ValidationError(
                ngettext(
                    "This password is too short. It must contain at least %(min_length)d character.",
                    "This password is too short. It must contain at least %(min_length)d characters.",
                    self.min_length
                ),
                code='password_too_short',
                params={'min_length': self.min_length},
            )

I do not know why it is not translated to your language.

2 Likes

Yes you are right, and actually django.contrib.auth has its own translation, look below you can find its translated.

But I am not sure why it wasn’t picked up, there are few reasons for that, it could the version Django Open edX didn’t pick up the tranlation. Worth checking other strings that comes from django package to get insight. Like is it just this string? Or do we dont get Django builtin translated strings in general?

1 Like

Thank you both for the help!

I believe it is caused by the fact that we are using zh_CN instead of zh_HANS.