chore: rewrite user-facing messages in Selling module

Conservative cleanup of frappe.throw/msgprint messages per the message style
guide; meaning, severity, and .format() arguments are unchanged:

- index bare {} placeholders as {0}/{1}/... so translators can reorder
- move f-strings / .format() / concatenation out of _() (they break gettext
  extraction and never translate)
- wrap translatable dynamic values (DocType/Select labels) in _()
- fix grammar and colloquialisms
- drop no-op _() wrapping runtime-built strings

Part of #53976.
This commit is contained in:
Mihir Kandoi
2026-06-25 16:15:01 +05:30
parent 9b4c8a8d7f
commit 33562a6a86
7 changed files with 14 additions and 12 deletions

View File

@@ -158,7 +158,7 @@ class Customer(TransactionBase):
new_customer_name = f"{self.customer_name} - {cstr(count)}"
msgprint(
_("Changed customer name to '{}' as '{}' already exists.").format(
_("Changed customer name to '{0}' as '{1}' already exists.").format(
new_customer_name, self.customer_name
),
title=_("Note"),
@@ -356,7 +356,7 @@ class Customer(TransactionBase):
if frappe.db.exists("Customer Group", self.name):
frappe.throw(
_(
"A Customer Group exists with same name please change the Customer name or rename the Customer Group"
"A Customer Group exists with the same name. Please change the Customer name or rename the Customer Group"
),
frappe.NameError,
)
@@ -406,7 +406,7 @@ class Customer(TransactionBase):
if flt(limit.credit_limit) < outstanding_amt:
frappe.throw(
_(
"""New credit limit is less than current outstanding amount for the customer. Credit limit has to be atleast {0}"""
"""New credit limit is less than current outstanding amount for the customer. Credit limit has to be at least {0}"""
).format(outstanding_amt)
)
@@ -440,7 +440,7 @@ class Customer(TransactionBase):
self.loyalty_program = loyalty_program[0]
else:
frappe.msgprint(
_("Multiple Loyalty Programs found for Customer {}. Please select manually.").format(
_("Multiple Loyalty Programs found for Customer {0}. Please select manually.").format(
frappe.bold(self.customer_name)
)
)

View File

@@ -172,7 +172,7 @@ def make_address(args, is_primary_address=1, is_shipping_address=1):
if reqd_fields:
msg = _("Following fields are mandatory to create address:")
frappe.throw(
"{} <br><br> <ul>{}</ul>".format(msg, "\n".join(reqd_fields)),
msg + " <br><br> <ul>{}</ul>".format("\n".join(reqd_fields)),
title=_("Missing Values Required"),
)

View File

@@ -32,4 +32,6 @@ class PartySpecificItem(Document):
},
)
if exists:
frappe.throw(_("This item filter has already been applied for the {0}").format(self.party_type))
frappe.throw(
_("This item filter has already been applied for the {0}").format(_(self.party_type))
)

View File

@@ -118,9 +118,9 @@ class ProductBundle(Document):
if len(invoice_links):
frappe.throw(
"This Product Bundle is linked with {}. You will have to cancel these documents in order to delete this Product Bundle".format(
", ".join(invoice_links)
),
_(
"This Product Bundle is linked with {0}. You will have to cancel these documents in order to delete this Product Bundle"
).format(", ".join(invoice_links)),
title=_("Not Allowed"),
)

View File

@@ -16,7 +16,7 @@ def validate_filters(from_date, to_date, company):
frappe.throw(_("To Date must be greater than From Date"))
if not company:
frappe.throw(_("Please Select a Company"))
frappe.throw(_("Please select a Company"))
@frappe.whitelist()

View File

@@ -47,7 +47,7 @@ class SalesPartnerSummaryReport:
frappe.throw(_("Please select the document type first."))
if self.filters.get("doctype") not in SALES_TRANSACTION_DOCTYPES:
frappe.throw(_("DocType can be one of them {0}").format(comma_or(SALES_TRANSACTION_DOCTYPES)))
frappe.throw(_("DocType can be one of {0}").format(comma_or(SALES_TRANSACTION_DOCTYPES)))
if not self.filters.get("company"):
frappe.throw(_("Please select a company."))

View File

@@ -19,7 +19,7 @@ class SalesPartnerSummaryReportTestMixin(ERPNextTestSuite):
with self.assertRaisesRegex(
frappe.ValidationError,
_("DocType can be one of them {0}").format(comma_or(SALES_TRANSACTION_DOCTYPES)),
_("DocType can be one of {0}").format(comma_or(SALES_TRANSACTION_DOCTYPES)),
):
run(self.report_name, self.filters)