collective / collective.pwexpiry

Emulate Active Directory password complexity requirements.
1 stars 6 forks source link

pwdisable plugin error message not translated #11

Closed frisi closed 8 years ago

frisi commented 8 years ago

the status message is not translated because zope looks up a message id containing the user_disabled_time ('str %s' % 'foo' is evaluated before passing the string to zope.i18n.translate)

IStatusMessage(self.REQUEST).add(
    _(u'Your account has been locked due to too many invalid '
        'attempts to login with a wrong password. Your account will '
        'remain blocked for the next %s hours. You can reset your '
        'password, or contact an administrator to unlock it, using '
        'the Contact form.' %
        user_disabled_time), type='error'
)

personally i prefere to use messageids so we can change the english text (i.e typos) without the need to fix/update translations.

to fix this use this syntax::

IStatusMessage(self.REQUEST).add(
    _(u'account_locked',
       default = u'Your account has been locked due to too many invalid '
        'attempts to login with a wrong password. Your account will '
        'remain blocked for the next ${hrs} hours. You can reset your '
        'password, or contact an administrator to unlock it, using '
        'the Contact form.', mapping={'hrs': user_disabled_time}
        ), type='error'
)

this requires to sync translations (and copy the existing translations strings for this text for all languages before syncing and pasting them afterwards. otherwhise they get lost)

the german translation sounds a bit "holprig":

Ihre Konto wurde gesperrt aufgrund von zu vielen ungültigen Anmeldungen. Ihr Konto bleibt gesperrt für die nächsten ${hrs} Stunden. Sie können Ihr Passwort zurücksetzen oder einen Administrator über das Kontakt Formular kontaktieren um es zu entsperren.

and should be replaced with this

Ihr Konto wurde aufgrund von zu vielen ungültigen Anmeldungen für die nächsten ${hrs} Stunden gesperrt. Sie können Ihr Passwort zurücksetzen oder einen Administrator über das Kontakt Formular bitten es zu entsperren.

frisi commented 8 years ago

@frapell what's your opinion on using msgids for translations?

frapell commented 8 years ago

@frisi I prefer to not use msgid, however I see your point on fixing a typo without needing to update translation... however if you fix a typo in the default value, you still need to update the translation files in order to have everything up to date... I find that having a script to update translation files usually is a good way to keep everything up to date (you just need to run one command to get translations updated, instead of having to remember long i18ndude commands...).

What do worries me is the mapping issue... isn't there a way to have this working without the need to switch to msgids ?

frisi commented 8 years ago

thanks for your feedback @frapell there is no need to use messageids to get the translations working and as you voted against them we won't introduce them.