From 08664181d44920b2874afb451859040546ea8bbd Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Thu, 25 Jun 2026 17:26:40 +0530 Subject: [PATCH] chore: rewrite user-facing JS messages in Stock 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. --- erpnext/stock/doctype/delivery_trip/delivery_trip.js | 10 +++++----- .../doctype/purchase_receipt/purchase_receipt.js | 2 +- erpnext/stock/doctype/shipment/shipment.js | 7 ++++--- .../stock/doctype/stock_settings/stock_settings.js | 2 +- .../stock_and_account_value_comparison.js | 11 +++++------ .../stock_ledger_invariant_check.js | 11 +++++------ .../stock_ledger_variance/stock_ledger_variance.js | 11 +++++------ 7 files changed, 26 insertions(+), 28 deletions(-) diff --git a/erpnext/stock/doctype/delivery_trip/delivery_trip.js b/erpnext/stock/doctype/delivery_trip/delivery_trip.js index 9eb5b1f83c3..79b706656db 100755 --- a/erpnext/stock/doctype/delivery_trip/delivery_trip.js +++ b/erpnext/stock/doctype/delivery_trip/delivery_trip.js @@ -89,10 +89,10 @@ frappe.ui.form.on("Delivery Trip", { calculate_arrival_time: function (frm) { if (!frm.doc.driver_address) { - frappe.throw(__("Cannot Calculate Arrival Time as Driver Address is Missing.")); + frappe.throw(__("Cannot calculate arrival time as the driver address is missing.")); } frappe.show_alert({ - message: "Calculating Arrival Times", + message: __("Calculating arrival times"), indicator: "orange", }); frm.call( @@ -122,10 +122,10 @@ frappe.ui.form.on("Delivery Trip", { optimize_route: function (frm) { if (!frm.doc.driver_address) { - frappe.throw(__("Cannot Optimize Route as Driver Address is Missing.")); + frappe.throw(__("Cannot optimize route as the driver address is missing.")); } frappe.show_alert({ - message: "Optimizing Route", + message: __("Optimizing route"), indicator: "orange", }); frm.call( @@ -143,7 +143,7 @@ frappe.ui.form.on("Delivery Trip", { $.each(frm.doc.delivery_stops || [], function (i, delivery_stop) { if (!delivery_stop.delivery_note) { frappe.msgprint({ - message: __("No Delivery Note selected for Customer {}", [delivery_stop.customer]), + message: __("No Delivery Note selected for Customer {0}", [delivery_stop.customer]), title: __("Warning"), indicator: "orange", alert: 1, diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js index 6524bd30265..71d2265879e 100644 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js @@ -353,7 +353,7 @@ erpnext.stock.PurchaseReceiptController = class PurchaseReceiptController extend frappe.set_route("Form", doc.doctype, doc.name); } else { frappe.msgprint( - __("Purchase Receipt doesn't have any Item for which Retain Sample is enabled.") + __("Purchase Receipt does not have any Item for which Retain Sample is enabled.") ); } }, diff --git a/erpnext/stock/doctype/shipment/shipment.js b/erpnext/stock/doctype/shipment/shipment.js index f22139c89f5..2672bdd1d73 100644 --- a/erpnext/stock/doctype/shipment/shipment.js +++ b/erpnext/stock/doctype/shipment/shipment.js @@ -439,9 +439,10 @@ frappe.ui.form.on("Shipment Delivery Note", { let row_index = row.idx - 1; if (validate_duplicate(frm, "shipment_delivery_note", row.delivery_note, row_index)) { frappe.throw( - __("You have entered a duplicate Delivery Note on Row") + - ` ${row.idx}. ` + - __("Please rectify and try again.") + __( + "You have entered a duplicate Delivery Note on row {0}. Please rectify and try again.", + [row.idx] + ) ); } } diff --git a/erpnext/stock/doctype/stock_settings/stock_settings.js b/erpnext/stock/doctype/stock_settings/stock_settings.js index 3d70c199d05..5fd07e78289 100644 --- a/erpnext/stock/doctype/stock_settings/stock_settings.js +++ b/erpnext/stock/doctype/stock_settings/stock_settings.js @@ -90,7 +90,7 @@ frappe.ui.form.on("Stock Settings", { if (!frm.doc.disable_serial_no_and_batch_selector && frm.doc.use_serial_batch_fields) { frm.set_value("disable_serial_no_and_batch_selector", 1); frappe.msgprint( - __("Serial No and Batch Selector cannot be use when Use Serial / Batch Fields is enabled.") + __("Serial No and Batch Selector cannot be used when Use Serial / Batch Fields is enabled.") ); } }, diff --git a/erpnext/stock/report/stock_and_account_value_comparison/stock_and_account_value_comparison.js b/erpnext/stock/report/stock_and_account_value_comparison/stock_and_account_value_comparison.js index 1e2022e66d5..00a720df8ae 100644 --- a/erpnext/stock/report/stock_and_account_value_comparison/stock_and_account_value_comparison.js +++ b/erpnext/stock/report/stock_and_account_value_comparison/stock_and_account_value_comparison.js @@ -44,12 +44,11 @@ frappe.query_reports["Stock and Account Value Comparison"] = { report.page.add_inner_button(__("Create Reposting Entries"), function () { let message = `

- Reposting Entries will change the value of - accounts Stock In Hand, and Stock Expenses - in the Trial Balance report and will also change - the Balance Value in the Stock Balance report. + ${__( + "Reposting Entries will change the value of accounts Stock In Hand, and Stock Expenses in the Trial Balance report and will also change the Balance Value in the Stock Balance report." + )}

-

Are you sure you want to create Reposting Entries?

+

${__("Are you sure you want to create Reposting Entries?")}

`; let indexes = frappe.query_report.datatable.rowmanager.getCheckedRows(); @@ -59,7 +58,7 @@ frappe.query_reports["Stock and Account Value Comparison"] = { frappe.throw(__("Please select rows to create Reposting Entries")); } - frappe.confirm(__(message), () => { + frappe.confirm(message, () => { frappe.call({ method: "erpnext.stock.report.stock_and_account_value_comparison.stock_and_account_value_comparison.create_reposting_entries", args: { diff --git a/erpnext/stock/report/stock_ledger_invariant_check/stock_ledger_invariant_check.js b/erpnext/stock/report/stock_ledger_invariant_check/stock_ledger_invariant_check.js index 1f405cda78f..feb8370870c 100644 --- a/erpnext/stock/report/stock_ledger_invariant_check/stock_ledger_invariant_check.js +++ b/erpnext/stock/report/stock_ledger_invariant_check/stock_ledger_invariant_check.js @@ -59,12 +59,11 @@ frappe.query_reports["Stock Ledger Invariant Check"] = { let message = `

- Reposting Entry will change the value of - accounts Stock In Hand, and Stock Expenses - in the Trial Balance report and will also change - the Balance Value in the Stock Balance report. + ${__( + "Reposting Entry will change the value of accounts Stock In Hand and Stock Expenses in the Trial Balance report and will also change the Balance Value in the Stock Balance report." + )}

-

Are you sure you want to create a Reposting Entry?

+

${__("Are you sure you want to create a Reposting Entry?")}

`; let indexes = frappe.query_report.datatable.rowmanager.getCheckedRows(); let selected_rows = indexes.map((i) => frappe.query_report.data[i]); @@ -74,7 +73,7 @@ frappe.query_reports["Stock Ledger Invariant Check"] = { } else if (selected_rows.length > 1) { frappe.throw(__("Please select only one row to create a Reposting Entry")); } else { - frappe.confirm(__(message), () => { + frappe.confirm(message, () => { frappe.call({ method: "erpnext.stock.report.stock_ledger_invariant_check.stock_ledger_invariant_check.create_reposting_entries", args: { diff --git a/erpnext/stock/report/stock_ledger_variance/stock_ledger_variance.js b/erpnext/stock/report/stock_ledger_variance/stock_ledger_variance.js index 5dfb6627662..e2235b95d8d 100644 --- a/erpnext/stock/report/stock_ledger_variance/stock_ledger_variance.js +++ b/erpnext/stock/report/stock_ledger_variance/stock_ledger_variance.js @@ -93,12 +93,11 @@ frappe.query_reports["Stock Ledger Variance"] = { let message = `

- Reposting Entries will change the value of - accounts Stock In Hand, and Stock Expenses - in the Trial Balance report and will also change - the Balance Value in the Stock Balance report. + ${__( + "Reposting Entries will change the value of accounts Stock In Hand, and Stock Expenses in the Trial Balance report and will also change the Balance Value in the Stock Balance report." + )}

-

Are you sure you want to create Reposting Entries?

+

${__("Are you sure you want to create Reposting Entries?")}

`; let indexes = frappe.query_report.datatable.rowmanager.getCheckedRows(); let selected_rows = indexes.map((i) => frappe.query_report.data[i]); @@ -107,7 +106,7 @@ frappe.query_reports["Stock Ledger Variance"] = { frappe.throw(__("Please select rows to create Reposting Entries")); } - frappe.confirm(__(message), () => { + frappe.confirm(message, () => { frappe.call({ method: "erpnext.stock.report.stock_ledger_invariant_check.stock_ledger_invariant_check.create_reposting_entries", args: {