Messages not translating

I have a msg return in form_valid method for successful user logout

messages.success(request, _(‘User logout successfully.’))

In login template i have msg block which shows the message if exists

Im translating the message using

{% translate message %}

But it is giving me an error i.e.

‘Message’ object has no attribute ‘replace’.