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.
This commit is contained in:
Mihir Kandoi
2026-06-25 17:26:40 +05:30
parent b0887e03fe
commit 08664181d4
7 changed files with 26 additions and 28 deletions

View File

@@ -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,

View File

@@ -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.")
);
}
},

View File

@@ -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]
)
);
}
}

View File

@@ -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.")
);
}
},

View File

@@ -44,12 +44,11 @@ frappe.query_reports["Stock and Account Value Comparison"] = {
report.page.add_inner_button(__("Create Reposting Entries"), function () {
let message = `<div>
<p>
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."
)}
</p>
<p>Are you sure you want to create Reposting Entries?</p>
<p>${__("Are you sure you want to create Reposting Entries?")}</p>
</div>
`;
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: {

View File

@@ -59,12 +59,11 @@ frappe.query_reports["Stock Ledger Invariant Check"] = {
let message = `
<div>
<p>
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."
)}
</p>
<p>Are you sure you want to create a Reposting Entry?</p>
<p>${__("Are you sure you want to create a Reposting Entry?")}</p>
</div>`;
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: {

View File

@@ -93,12 +93,11 @@ frappe.query_reports["Stock Ledger Variance"] = {
let message = `
<div>
<p>
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."
)}
</p>
<p>Are you sure you want to create Reposting Entries?</p>
<p>${__("Are you sure you want to create Reposting Entries?")}</p>
</div>`;
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: {