Skip to content

Commit

Permalink
fix: translatability of boldened text
Browse files Browse the repository at this point in the history
(cherry picked from commit af0ae93)

# Conflicts:
#	erpnext/controllers/accounts_controller.py
  • Loading branch information
barredterra authored and mergify[bot] committed Aug 17, 2024
1 parent 8514c01 commit 4914481
Show file tree
Hide file tree
Showing 19 changed files with 54 additions and 50 deletions.
2 changes: 1 addition & 1 deletion erpnext/accounts/doctype/account/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def validate_receivable_payable_account_type(self):
msg = _(
"There are ledger entries against this account. Changing {0} to non-{1} in live system will cause incorrect output in 'Accounts {2}' report"
).format(
frappe.bold("Account Type"), doc_before_save.account_type, doc_before_save.account_type
frappe.bold(_("Account Type")), doc_before_save.account_type, doc_before_save.account_type
)
frappe.msgprint(msg)
self.add_comment("Comment", msg)
Expand Down
10 changes: 3 additions & 7 deletions erpnext/accounts/doctype/pos_closing_entry/pos_closing_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,15 @@ def validate_pos_invoices(self):
as_dict=1,
)[0]
if pos_invoice.consolidated_invoice:
invalid_row.setdefault("msg", []).append(
_("POS Invoice is {}").format(frappe.bold("already consolidated"))
)
invalid_row.setdefault("msg", []).append(_("POS Invoice is already consolidated"))
invalid_rows.append(invalid_row)
continue
if pos_invoice.pos_profile != self.pos_profile:
invalid_row.setdefault("msg", []).append(
_("POS Profile doesn't matches {}").format(frappe.bold(self.pos_profile))
_("POS Profile doesn't match {}").format(frappe.bold(self.pos_profile))
)
if pos_invoice.docstatus != 1:
invalid_row.setdefault("msg", []).append(
_("POS Invoice is not {}").format(frappe.bold("submitted"))
)
invalid_row.setdefault("msg", []).append(_("POS Invoice is not submitted"))
if pos_invoice.owner != self.user:
invalid_row.setdefault("msg", []).append(
_("POS Invoice isn't created by user {}").format(frappe.bold(self.owner))
Expand Down
2 changes: 1 addition & 1 deletion erpnext/accounts/doctype/pos_invoice/pos_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def __init__(self, *args, **kwargs):
def validate(self):
if not cint(self.is_pos):
frappe.throw(
_("POS Invoice should have {} field checked.").format(frappe.bold("Include Payment"))
_("POS Invoice should have the field {0} checked.").format(frappe.bold(_("Include Payment")))
)

# run on validate method of selling controller
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,15 @@ def validate_pos_invoice_status(self):
return_against_status = frappe.db.get_value("POS Invoice", return_against, "status")
if return_against_status != "Consolidated":
# if return entry is not getting merged in the current pos closing and if it is not consolidated
bold_unconsolidated = frappe.bold("not Consolidated")
msg = _("Row #{}: Original Invoice {} of return invoice {} is {}.").format(
d.idx, bold_return_against, bold_pos_invoice, bold_unconsolidated
)
msg = _(
"Row #{}: The original Invoice {} of return invoice {} is not consolidated."
).format(d.idx, bold_return_against, bold_pos_invoice)
msg += " "
msg += _(
"Original invoice should be consolidated before or along with the return invoice."
"The original invoice should be consolidated before or along with the return invoice."
)
msg += "<br><br>"
msg += _("You can add original invoice {} manually to proceed.").format(
msg += _("You can add the original invoice {} manually to proceed.").format(
bold_return_against
)
frappe.throw(msg)
Expand Down
5 changes: 3 additions & 2 deletions erpnext/accounts/doctype/pricing_rule/pricing_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,16 @@ def validate_mandatory(self):
if not self.priority:
throw(
_("As the field {0} is enabled, the field {1} is mandatory.").format(
frappe.bold("Apply Discount on Discounted Rate"), frappe.bold("Priority")
frappe.bold(_("Apply Discount on Discounted Rate")),
frappe.bold(_("Priority")),
)
)

if self.priority and cint(self.priority) == 1:
throw(
_(
"As the field {0} is enabled, the value of the field {1} should be more than 1."
).format(frappe.bold("Apply Discount on Discounted Rate"), frappe.bold("Priority"))
).format(frappe.bold(_("Apply Discount on Discounted Rate")), frappe.bold(_("Priority")))
)

def validate_applicable_for_selling_or_buying(self):
Expand Down
12 changes: 6 additions & 6 deletions erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,16 +377,16 @@ def validate_credit_to_acc(self):
if account.report_type != "Balance Sheet":
frappe.throw(
_(
"Please ensure {} account is a Balance Sheet account. You can change the parent account to a Balance Sheet account or select a different account."
).format(frappe.bold("Credit To")),
"Please ensure that the {0} account is a Balance Sheet account. You can change the parent account to a Balance Sheet account or select a different account."
).format(frappe.bold(_("Credit To"))),
title=_("Invalid Account"),
)

if self.supplier and account.account_type != "Payable":
frappe.throw(
_(
"Please ensure {} account {} is a Payable account. Change the account type to Payable or select a different account."
).format(frappe.bold("Credit To"), frappe.bold(self.credit_to)),
"Please ensure that the {0} account {1} is a Payable account. You can change the account type to Payable or select a different account."
).format(frappe.bold(_("Credit To")), frappe.bold(self.credit_to)),
title=_("Invalid Account"),
)

Expand Down Expand Up @@ -634,7 +634,7 @@ def po_required(self):
"To submit the invoice without purchase order please set {0} as {1} in {2}"
).format(
frappe.bold(_("Purchase Order Required")),
frappe.bold("No"),
frappe.bold(_("No")),
get_link_to_form("Buying Settings", "Buying Settings", "Buying Settings"),
)
throw(msg, title=_("Mandatory Purchase Order"))
Expand All @@ -655,7 +655,7 @@ def pr_required(self):
"To submit the invoice without purchase receipt please set {0} as {1} in {2}"
).format(
frappe.bold(_("Purchase Receipt Required")),
frappe.bold("No"),
frappe.bold(_("No")),
get_link_to_form("Buying Settings", "Buying Settings", "Buying Settings"),
)
throw(msg, title=_("Mandatory Purchase Receipt"))
Expand Down
6 changes: 3 additions & 3 deletions erpnext/accounts/doctype/sales_invoice/sales_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ def check_if_consolidated_invoice(self):
)
if pos_closing_entry and pos_closing_entry[0]:
msg = _("To cancel a {} you need to cancel the POS Closing Entry {}.").format(
frappe.bold("Consolidated Sales Invoice"),
frappe.bold(_("Consolidated Sales Invoice")),
get_link_to_form("POS Closing Entry", pos_closing_entry[0]),
)
frappe.throw(msg, title=_("Not Allowed"))
Expand Down Expand Up @@ -858,7 +858,7 @@ def validate_debit_to_acc(self):

if account.report_type != "Balance Sheet":
msg = (
_("Please ensure {} account is a Balance Sheet account.").format(frappe.bold("Debit To"))
_("Please ensure {} account is a Balance Sheet account.").format(frappe.bold(_("Debit To")))
+ " "
)
msg += _(
Expand All @@ -869,7 +869,7 @@ def validate_debit_to_acc(self):
if self.customer and account.account_type != "Receivable":
msg = (
_("Please ensure {} account {} is a Receivable account.").format(
frappe.bold("Debit To"), frappe.bold(self.debit_to)
frappe.bold(_("Debit To")), frappe.bold(self.debit_to)
)
+ " "
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ def get_tds_docs(filters):
def get_tds_docs_query(filters, bank_accounts, tds_accounts):
if not tds_accounts:
frappe.throw(
_("No {0} Accounts found for this company.").format(frappe.bold("Tax Withholding")),
_("No {0} Accounts found for this company.").format(frappe.bold(_("Tax Withholding"))),
title=_("Accounts Missing Error"),
)
gle = frappe.qb.DocType("GL Entry")
Expand Down
2 changes: 1 addition & 1 deletion erpnext/assets/doctype/asset/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ def get_fixed_asset_account(self):
if not fixed_asset_account:
frappe.throw(
_("Set {0} in asset category {1} for company {2}").format(
frappe.bold("Fixed Asset Account"),
frappe.bold(_("Fixed Asset Account")),
frappe.bold(self.asset_category),
frappe.bold(self.company),
),
Expand Down
15 changes: 11 additions & 4 deletions erpnext/controllers/accounts_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,13 @@ def validate(self):
).format(
frappe.bold(document_type),
get_link_to_form(self.doctype, self.get("return_against")),
<<<<<<< HEAD
frappe.bold("Update Outstanding for Self"),
get_link_to_form("Payment Reconciliation", "Payment Reconciliation"),
=======
frappe.bold(_("Update Outstanding for Self")),
get_link_to_form("Payment Reconciliation"),
>>>>>>> af0ae930ca (fix: translatability of boldened text)
)
)

Expand Down Expand Up @@ -1962,7 +1967,9 @@ def company_abbr(self):

def raise_missing_debit_credit_account_error(self, party_type, party):
"""Raise an error if debit to/credit to account does not exist."""
db_or_cr = frappe.bold("Debit To") if self.doctype == "Sales Invoice" else frappe.bold("Credit To")
db_or_cr = (
frappe.bold(_("Debit To")) if self.doctype == "Sales Invoice" else frappe.bold(_("Credit To"))
)
rec_or_pay = "Receivable" if self.doctype == "Sales Invoice" else "Payable"

link_to_party = frappe.utils.get_link_to_form(party_type, party)
Expand Down Expand Up @@ -3085,9 +3092,9 @@ def set_order_defaults(parent_doctype, parent_doctype_name, child_doctype, child
child_item.warehouse = get_item_warehouse(item, p_doc, overwrite_warehouse=True)
if not child_item.warehouse:
frappe.throw(
_("Cannot find {} for item {}. Please set the same in Item Master or Stock Settings.").format(
frappe.bold("default warehouse"), frappe.bold(item.item_code)
)
_(
"Cannot find a default warehouse for item {0}. Please set one in the Item Master or in Stock Settings."
).format(frappe.bold(item.item_code))
)

set_child_tax_template_and_map(item, child_item, p_doc)
Expand Down
2 changes: 1 addition & 1 deletion erpnext/controllers/item_variant.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def validate_item_attribute_value(attributes_list, attribute, attribute_value, i
)
msg += "<br>" + _(
"To still proceed with editing this Attribute Value, enable {0} in Item Variant Settings."
).format(frappe.bold("Allow Rename Attribute Value"))
).format(frappe.bold(_("Allow Rename Attribute Value")))

frappe.throw(msg, InvalidItemAttributeValueError, title=_("Edit Not Allowed"))

Expand Down
2 changes: 1 addition & 1 deletion erpnext/controllers/selling_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ def validate_for_duplicate_items(self):
duplicate_items_msg = _("Item {0} entered multiple times.").format(frappe.bold(d.item_code))
duplicate_items_msg += "<br><br>"
duplicate_items_msg += _("Please enable {} in {} to allow same item in multiple rows").format(
frappe.bold("Allow Item to Be Added Multiple Times in a Transaction"),
frappe.bold(_("Allow Item to Be Added Multiple Times in a Transaction")),
get_link_to_form("Selling Settings", "Selling Settings"),
)
if frappe.db.get_value("Item", d.item_code, "is_stock_item") == 1:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def add_bank_accounts(response, bank, company):
frappe.throw(
_(
"Please setup and enable a group account with the Account Type - {0} for the company {1}"
).format(frappe.bold("Bank"), company)
).format(frappe.bold(_("Bank")), company)
)

for account in response["accounts"]:
Expand Down
6 changes: 3 additions & 3 deletions erpnext/setup/doctype/company/company.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def validate_advance_account_currency(self):
):
frappe.throw(
_("'{0}' should be in company currency {1}.").format(
frappe.bold("Default Advance Received Account"), frappe.bold(self.default_currency)
frappe.bold(_("Default Advance Received Account")), frappe.bold(self.default_currency)
)
)

Expand All @@ -214,7 +214,7 @@ def validate_advance_account_currency(self):
):
frappe.throw(
_("'{0}' should be in company currency {1}.").format(
frappe.bold("Default Advance Paid Account"), frappe.bold(self.default_currency)
frappe.bold(_("Default Advance Paid Account")), frappe.bold(self.default_currency)
)
)

Expand Down Expand Up @@ -447,7 +447,7 @@ def validate_provisional_account_for_non_stock_items(self):
):
frappe.throw(
_("Set default {0} account for non stock items").format(
frappe.bold("Provisional Account")
frappe.bold(_("Provisional Account"))
)
)

Expand Down
4 changes: 2 additions & 2 deletions erpnext/stock/doctype/batch/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,9 @@ def set_expiry_date(self):
if has_expiry_date and not self.expiry_date:
frappe.throw(
msg=_("Please set {0} for Batched Item {1}, which is used to set {2} on Submit.").format(
frappe.bold("Shelf Life in Days"),
frappe.bold(_("Shelf Life in Days")),
get_link_to_form("Item", self.item),
frappe.bold("Batch Expiry Date"),
frappe.bold(_("Batch Expiry Date")),
),
title=_("Expiry Date Mandatory"),
)
Expand Down
6 changes: 3 additions & 3 deletions erpnext/stock/doctype/stock_entry/stock_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -898,8 +898,8 @@ def get_basic_rate_for_manufactured_item(self, finished_item_qty, outgoing_items
).format(
item.idx,
frappe.bold(label),
frappe.bold("Manufacture"),
frappe.bold("Material Consumption for Manufacture"),
frappe.bold(_("Manufacture")),
frappe.bold(_("Material Consumption for Manufacture")),
)
)

Expand All @@ -909,7 +909,7 @@ def get_basic_rate_for_manufactured_item(self, finished_item_qty, outgoing_items
):
frappe.throw(
_("Only one {0} entry can be created against the Work Order {1}").format(
frappe.bold("Manufacture"), frappe.bold(self.work_order)
frappe.bold(_("Manufacture")), frappe.bold(self.work_order)
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def validate_reservation_based_on_serial_and_batch(self) -> None:
if self.has_batch_no
else _("Warehouse"),
frappe.bold(self.warehouse),
frappe.bold("Stock Reservation Entry"),
frappe.bold(_("Stock Reservation Entry")),
)

frappe.throw(msg)
Expand Down Expand Up @@ -497,7 +497,8 @@ def validate_stock_reservation_settings(voucher: object) -> None:

if not frappe.db.get_single_value("Stock Settings", "enable_stock_reservation"):
msg = _("Please enable {0} in the {1}.").format(
frappe.bold("Stock Reservation"), frappe.bold("Stock Settings")
frappe.bold(_("Stock Reservation")),
frappe.bold(_("Stock Settings")),
)
frappe.throw(msg)

Expand Down
8 changes: 4 additions & 4 deletions erpnext/stock/doctype/stock_settings/stock_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def validate_stock_reservation(self):
if self.allow_negative_stock and self.enable_stock_reservation:
frappe.throw(
_("As {0} is enabled, you can not enable {1}.").format(
frappe.bold("Stock Reservation"), frappe.bold("Allow Negative Stock")
frappe.bold(_("Stock Reservation")), frappe.bold(_("Allow Negative Stock"))
)
)

Expand All @@ -187,7 +187,7 @@ def validate_stock_reservation(self):
if self.allow_negative_stock:
frappe.throw(
_("As {0} is enabled, you can not enable {1}.").format(
frappe.bold("Allow Negative Stock"), frappe.bold("Stock Reservation")
frappe.bold(_("Allow Negative Stock")), frappe.bold(_("Stock Reservation"))
)
)

Expand All @@ -207,7 +207,7 @@ def validate_stock_reservation(self):
if bin_with_negative_stock:
frappe.throw(
_("As there are negative stock, you can not enable {0}.").format(
frappe.bold("Stock Reservation")
frappe.bold(_("Stock Reservation"))
)
)

Expand All @@ -221,7 +221,7 @@ def validate_stock_reservation(self):
if has_reserved_stock:
frappe.throw(
_("As there are reserved stock, you cannot disable {0}.").format(
frappe.bold("Stock Reservation")
frappe.bold(_("Stock Reservation"))
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def validate_doc(self):
):
frappe.throw(
_("{0} is not enabled in {1}").format(
frappe.bold("Track Service Level Agreement"),
frappe.bold(_("Track Service Level Agreement")),
get_link_to_form("Support Settings", "Support Settings"),
)
)
Expand Down

0 comments on commit 4914481

Please sign in to comment.