Transaction _ help

How can I add the following text to the “Transaction” so that it get translated??
msg = f"Row #{row.idx}: Quality Inspection is required for Item {frappe.bold(row.item_code)}"

the following code doesn’t work.
Row #{0}: Quality Inspection is required for Item {1}

Hi @raha ,

If you want your message to be translatable in Frappe, don’t use f-strings. Instead, do this:

msg = _("Row #{0}: Quality Inspection is required for Item {1}").format(row.idx, frappe.bold(row.item_code))

This way, Frappe can pick up the string for translation.

Hope that helps!

thanks.
It’s a system code and I don’t want to change the core code.

Ah, gotcha! If you don’t want to change the core code, just add a custom translation:

  • Go to Translations in the UI
  • Add:
    • Source Text: Row #{0}: Quality Inspection is required for Item {1}
    • Your translated text
    • Set the language

That way, you can translate it without touching the original code.

Let me know if you need help with that!

thanks
but
doesn’t work. :smiling_face_with_tear:

Are you getting any kind of errors?

No, I don’t get any errors, but only this part of the code isn’t being translated. I’ve tested all the structures as well.