How to automatically flag strings for makemessage translation file in django

122 Views Asked by At

I'm creating a signal that sends messages to multiple users, and each message should be translated to the receiver's language.

this is a simplified example of that the alert handler does:

def alert_handler(**kwargs):
    t_message = kwargs.pop("message", None)
    context = kwargs.pop("context", None)

    for recipient in recipients:
        activate(recipient.language)
        message = _(t_message, context)
        new_alert = Alert(recipient=recipient, message=message)
       

This works as intended but the makemessages command doesn't recognize the sting passed in the kwargs as a translatable string.

Is it possible to flag a string to be picked up by the makemessages command?

0

There are 0 best solutions below