fix(translations): Replace translations by keyword with indexed version (#15426)

* fix(translations): Replace translations by keyword with indexed version

Keywords in the translation also gets translated which
results in an error because python cannot find the key

* Update buying_controller.py
This commit is contained in:
Faris Ansari 2018-09-19 13:13:59 +05:30 committed by Nabin Hait
parent 63a58a6752
commit 2ab6e0e39b
4 changed files with 15 additions and 17 deletions

View File

@ -61,7 +61,7 @@ class OpeningInvoiceCreationTool(Document):
def make_invoices(self): def make_invoices(self):
names = [] names = []
mandatory_error_msg = _("Row {idx}: {field} is required to create the Opening {invoice_type} Invoices") mandatory_error_msg = _("Row {0}: {1} is required to create the Opening {2} Invoices")
if not self.company: if not self.company:
frappe.throw(_("Please select the Company")) frappe.throw(_("Please select the Company"))
@ -90,11 +90,7 @@ class OpeningInvoiceCreationTool(Document):
for d in ("Party", "Outstanding Amount", "Temporary Opening Account"): for d in ("Party", "Outstanding Amount", "Temporary Opening Account"):
if not row.get(scrub(d)): if not row.get(scrub(d)):
frappe.throw(mandatory_error_msg.format( frappe.throw(mandatory_error_msg.format(row.idx, _(d), self.invoice_type))
idx=row.idx,
field=_(d),
invoice_type=self.invoice_type
))
args = self.get_invoice_dict(row=row) args = self.get_invoice_dict(row=row)
if not args: if not args:

View File

@ -772,8 +772,7 @@ class AccountsController(TransactionBase):
if li: if li:
duplicates = '<br>' + '<br>'.join(li) duplicates = '<br>' + '<br>'.join(li)
frappe.throw(_("Rows with duplicate due dates in other rows were found: {list}") frappe.throw(_("Rows with duplicate due dates in other rows were found: {0}").format(duplicates))
.format(list=duplicates))
def validate_payment_schedule_amount(self): def validate_payment_schedule_amount(self):
if self.doctype == 'Sales Invoice' and self.is_pos: return if self.doctype == 'Sales Invoice' and self.is_pos: return

View File

@ -753,8 +753,11 @@ def validate_item_type(doc, fieldname, message):
""".format(item_list, fieldname), as_list=True)] """.format(item_list, fieldname), as_list=True)]
if invalid_items: if invalid_items:
frappe.throw(_("Following item {items} {verb} marked as {message} item.\ items = ", ".join([d for d in invalid_items])
You can enable them as {message} item from its Item master".format(
items = ", ".join([d for d in invalid_items]), if len(invalid_items) > 1:
verb = _("are not") if len(invalid_items) > 1 else _("is not"), error_message = _("Following items {0} are not marked as {1} item. You can enable them as {1} item from its Item master".format(items, message))
message = message))) else:
error_message = _("Following item {0} is not marked as {1} item. You can enable them as {1} item from its Item master".format(items, message))
frappe.throw(error_message)

View File

@ -60,8 +60,8 @@ class LandedCostVoucher(Document):
if not item.receipt_document: if not item.receipt_document:
frappe.throw(_("Item must be added using 'Get Items from Purchase Receipts' button")) frappe.throw(_("Item must be added using 'Get Items from Purchase Receipts' button"))
elif item.receipt_document not in receipt_documents: elif item.receipt_document not in receipt_documents:
frappe.throw(_("Item Row {idx}: {doctype} {docname} does not exist in above '{doctype}' table") frappe.throw(_("Item Row {0}: {1} {2} does not exist in above '{1}' table")
.format(idx=item.idx, doctype=item.receipt_document_type, docname=item.receipt_document)) .format(item.idx, item.receipt_document_type, item.receipt_document))
if not item.cost_center: if not item.cost_center:
frappe.throw(_("Row {0}: Cost center is required for an item {1}") frappe.throw(_("Row {0}: Cost center is required for an item {1}")