diff --git a/frappe/public/js/frappe/desk.js b/frappe/public/js/frappe/desk.js index 202cee645a..51ada70948 100644 --- a/frappe/public/js/frappe/desk.js +++ b/frappe/public/js/frappe/desk.js @@ -214,19 +214,20 @@ frappe.Application = class Application { email_password_prompt(email_account,user,i) { var me = this; + const email_id = email_account[i]["email_id"]; let d = new frappe.ui.Dialog({ title: __('Password missing in Email Account'), fields: [ { 'fieldname': 'password', 'fieldtype': 'Password', - 'label': __('Please enter the password for: {0}', [email_account[i]["email_id"]]), + 'label': __('Please enter the password for: {0}', [email_id], "Email Account"), 'reqd': 1 }, { "fieldname": "submit", "fieldtype": "Button", - "label": __("Submit") + "label": __("Submit", null, "Submit password for Email Account") } ] }); diff --git a/frappe/public/js/frappe/form/form.js b/frappe/public/js/frappe/form/form.js index 1459b38df6..510426a444 100644 --- a/frappe/public/js/frappe/form/form.js +++ b/frappe/public/js/frappe/form/form.js @@ -943,7 +943,10 @@ frappe.ui.form.Form = class FrappeForm { // re-enable buttons resolve(); } - frappe.throw (__("No permission to '{0}' {1}", [__(action), __(this.doc.doctype)])); + + frappe.throw( + __("No permission to '{0}' {1}", [__(action), __(this.doc.doctype)], "{0} = verb, {1} = object") + ); } } diff --git a/frappe/public/js/frappe/form/save.js b/frappe/public/js/frappe/form/save.js index 65d84e2202..934c90f017 100644 --- a/frappe/public/js/frappe/form/save.js +++ b/frappe/public/js/frappe/form/save.js @@ -7,12 +7,12 @@ frappe.ui.form.save = function (frm, action, callback, btn) { $(btn).prop("disabled", true); // specified here because there are keyboard shortcuts to save - var working_label = { - "Save": __("Saving"), - "Submit": __("Submitting"), - "Update": __("Updating"), - "Amend": __("Amending"), - "Cancel": __("Cancelling") + const working_label = { + "Save": __("Saving", null, "Freeze message while saving a document"), + "Submit": __("Submitting", null, "Freeze message while submitting a document"), + "Update": __("Updating", null, "Freeze message while updating a document"), + "Amend": __("Amending", null, "Freeze message while amending a document"), + "Cancel": __("Cancelling", null, "Freeze message while cancelling a document"), }[toTitle(action)]; var freeze_message = working_label ? __(working_label) : ""; @@ -154,8 +154,8 @@ frappe.ui.form.save = function (frm, action, callback, btn) { if (error_fields.length) { let meta = frappe.get_meta(doc.doctype); if (meta.istable) { - var message = __('Mandatory fields required in table {0}, Row {1}', - [__(frappe.meta.docfield_map[doc.parenttype][doc.parentfield].label).bold(), doc.idx]); + const table_label = __(frappe.meta.docfield_map[doc.parenttype][doc.parentfield].label).bold(); + var message = __('Mandatory fields required in table {0}, Row {1}', [table_label, doc.idx]); } else { var message = __('Mandatory fields required in {0}', [__(doc.doctype)]); } @@ -276,4 +276,3 @@ frappe.ui.form.update_calling_link = (newdoc) => { frappe._from_link = null; } } - diff --git a/frappe/public/js/frappe/list/list_view.js b/frappe/public/js/frappe/list/list_view.js index 22f8377a57..3cde04313f 100644 --- a/frappe/public/js/frappe/list/list_view.js +++ b/frappe/public/js/frappe/list/list_view.js @@ -200,7 +200,7 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { frappe.render_template("list_view_permission_restrictions", { condition_list: match_rules_list, }), - __("Restrictions") + __("Restrictions", null, "Title of message showing restrictions in list view") ); } @@ -255,8 +255,13 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { set_primary_action() { if (this.can_create) { + const doctype_name = __(frappe.router.doctype_layout) || __(this.doctype); + + // Better style would be __("Add {0}", [doctype_name], "Primary action in list view") + // Keeping it like this to not disrupt existing translations + const label = `${__("Add", null, "Primary action in list view")} ${doctype_name}`; this.page.set_primary_action( - `${__("Add")} ${frappe.router.doctype_layout || __(this.doctype)}`, + label, () => { if (this.settings.primary_action) { this.settings.primary_action(); @@ -320,9 +325,9 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { setup_freeze_area() { this.$freeze = $( - `
${__( - "Loading" - )}...
` + `
+ ${__("Loading")}... +
` ).hide(); this.$result.append(this.$freeze); } @@ -460,8 +465,8 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { ? __("No {0} found", [__(this.doctype)]) : __("You haven't created a {0} yet", [__(this.doctype)]); let new_button_label = filters && filters.length - ? __("Create a new {0}", [__(this.doctype)]) - : __("Create your first {0}", [__(this.doctype)]); + ? __("Create a new {0}", [__(this.doctype)], "Create a new document from list view") + : __("Create your first {0}", [__(this.doctype)], "Create a new document from list view"); let empty_state_image = this.settings.empty_state_image || "/assets/frappe/images/ui-states/list-empty-state.svg"; @@ -469,7 +474,9 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { const new_button = this.can_create ? `

` +

` : ""; return `
@@ -486,7 +493,7 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { if (this.list_view_settings && !this.list_view_settings.disable_count) { this.$result .find(".list-count") - .html(`${__("Refreshing")}...`); + .html(`${__("Refreshing", null, "Document count in list view")}...`); } } @@ -1081,14 +1088,14 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { frappe.ui.keys.add_shortcut({ shortcut: "down", action: () => handle_navigation("down"), - description: __("Navigate list down"), + description: __("Navigate list down", null, "Description of a list view shortcut"), page: this.page, }); frappe.ui.keys.add_shortcut({ shortcut: "up", action: () => handle_navigation("up"), - description: __("Navigate list up"), + description: __("Navigate list up", null, "Description of a list view shortcut"), page: this.page, }); @@ -1100,7 +1107,7 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { check_row($list_row); focus_next(); }, - description: __("Select multiple list items"), + description: __("Select multiple list items", null, "Description of a list view shortcut"), page: this.page, }); @@ -1112,7 +1119,7 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { check_row($list_row); focus_prev(); }, - description: __("Select multiple list items"), + description: __("Select multiple list items", null, "Description of a list view shortcut"), page: this.page, }); @@ -1126,7 +1133,7 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { } return false; }, - description: __("Open list item"), + description: __("Open list item", null, "Description of a list view shortcut"), page: this.page, }); @@ -1140,7 +1147,7 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { } return false; }, - description: __("Select list item"), + description: __("Select list item", null, "Description of a list view shortcut"), page: this.page, }); } @@ -1515,7 +1522,7 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { if (frappe.model.can_import(doctype, null, this.meta)) { items.push({ - label: __("Import"), + label: __("Import", null, "Button in list view menu"), action: () => frappe.set_route("list", "data-import", { reference_doctype: doctype, @@ -1526,7 +1533,7 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { if (frappe.model.can_set_user_permissions(doctype)) { items.push({ - label: __("User Permissions"), + label: __("User Permissions", null, "Button in list view menu"), action: () => frappe.set_route("list", "user-permission", { allow: doctype, @@ -1537,7 +1544,7 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { if (frappe.user_roles.includes("System Manager")) { items.push({ - label: __("Role Permissions Manager"), + label: __("Role Permissions Manager", null, "Button in list view menu"), action: () => frappe.set_route("permission-manager", { doctype, @@ -1546,7 +1553,7 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { }); items.push({ - label: __("Customize"), + label: __("Customize", null, "Button in list view menu"), action: () => { if (!this.meta) return; if (this.meta.custom) { @@ -1563,7 +1570,7 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { } items.push({ - label: __("Toggle Sidebar"), + label: __("Toggle Sidebar", null, "Button in list view menu"), action: () => this.toggle_side_bar(), condition: () => !this.hide_sidebar, standard: true, @@ -1571,7 +1578,7 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { }); items.push({ - label: __("Share URL"), + label: __("Share URL", null, "Button in list view menu"), action: () => this.share_url(), standard: true, shortcut: "Ctrl+L", @@ -1583,7 +1590,7 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { ) { // edit doctype items.push({ - label: __("Edit DocType"), + label: __("Edit DocType", null, "Button in list view menu"), action: () => frappe.set_route("form", "doctype", doctype), standard: true, }); @@ -1591,7 +1598,7 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { if (frappe.user.has_role("System Manager")) { items.push({ - label: __("List Settings"), + label: __("List Settings", null, "Button in list view menu"), action: () => this.show_list_settings(), standard: true, }); @@ -1682,7 +1689,7 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { // utility const bulk_assignment = () => { return { - label: __("Assign To"), + label: __("Assign To", null, "Button in list view actions menu"), action: () => { this.disable_list_update = true; bulk_operations.assign( @@ -1700,7 +1707,7 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { const bulk_assignment_rule = () => { return { - label: __("Apply Assignment Rule"), + label: __("Apply Assignment Rule", null, "Button in list view actions menu"), action: () => { this.disable_list_update = true; bulk_operations.apply_assignment_rule( @@ -1718,7 +1725,7 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { const bulk_add_tags = () => { return { - label: __("Add Tags"), + label: __("Add Tags", null, "Button in list view actions menu"), action: () => { this.disable_list_update = true; bulk_operations.add_tags( @@ -1736,7 +1743,7 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { const bulk_printing = () => { return { - label: __("Print"), + label: __("Print", null, "Button in list view actions menu"), action: () => bulk_operations.print(this.get_checked_items()), standard: true, }; @@ -1744,13 +1751,13 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { const bulk_delete = () => { return { - label: __("Delete"), + label: __("Delete", null, "Button in list view actions menu"), action: () => { const docnames = this.get_checked_items(true).map( (docname) => docname.toString() ); frappe.confirm( - __("Delete {0} items permanently?", [docnames.length]), + __("Delete {0} items permanently?", [docnames.length], "Title of confirmation dialog"), () => { this.disable_list_update = true; bulk_operations.delete(docnames, () => { @@ -1767,12 +1774,12 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { const bulk_cancel = () => { return { - label: __("Cancel"), + label: __("Cancel", null, "Button in list view actions menu"), action: () => { const docnames = this.get_checked_items(true); if (docnames.length > 0) { frappe.confirm( - __("Cancel {0} documents?", [docnames.length]), + __("Cancel {0} documents?", [docnames.length], "Title of confirmation dialog"), () => { this.disable_list_update = true; bulk_operations.submit_or_cancel( @@ -1793,12 +1800,12 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { const bulk_submit = () => { return { - label: __("Submit"), + label: __("Submit", null, "Button in list view actions menu"), action: () => { const docnames = this.get_checked_items(true); if (docnames.length > 0) { frappe.confirm( - __("Submit {0} documents?", [docnames.length]), + __("Submit {0} documents?", [docnames.length], "Title of confirmation dialog"), () => { this.disable_list_update = true; bulk_operations.submit_or_cancel( @@ -1820,7 +1827,7 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { const bulk_edit = () => { return { - label: __("Edit"), + label: __("Edit", null, "Button in list view actions menu"), action: () => { let field_mappings = {}; @@ -1850,7 +1857,7 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { const bulk_export = () => { return { - label: __("Export"), + label: __("Export", null, "Button in list view actions menu"), action: () => { const docnames = this.get_checked_items(true); diff --git a/frappe/public/js/frappe/ui/dialog.js b/frappe/public/js/frappe/ui/dialog.js index e2e51ce501..1618db9939 100644 --- a/frappe/public/js/frappe/ui/dialog.js +++ b/frappe/public/js/frappe/ui/dialog.js @@ -57,8 +57,10 @@ frappe.ui.Dialog = class Dialog extends frappe.ui.FieldGroup { // show footer this.action = this.action || { primary: { }, secondary: { } }; if (this.primary_action || (this.action.primary && this.action.primary.onsubmit)) { - this.set_primary_action(this.primary_action_label || this.action.primary.label || __("Submit"), - this.primary_action || this.action.primary.onsubmit); + this.set_primary_action( + this.primary_action_label || this.action.primary.label || __("Submit", null, "Primary action in dialog"), + this.primary_action || this.action.primary.onsubmit + ); } if (this.secondary_action) { diff --git a/frappe/public/js/frappe/ui/messages.js b/frappe/public/js/frappe/ui/messages.js index 0e0b6527e6..ac0c01c406 100644 --- a/frappe/public/js/frappe/ui/messages.js +++ b/frappe/public/js/frappe/ui/messages.js @@ -63,7 +63,7 @@ frappe.warn = function(title, message_html, proceed_action, primary_label, is_mi if (proceed_action) proceed_action(); d.hide(); }, - secondary_action_label: __("Cancel"), + secondary_action_label: __("Cancel", null, "Secondary button in warning dialog"), secondary_action: () => d.hide(), minimizable: is_minimizable }); diff --git a/frappe/public/js/frappe/web_form/web_form.js b/frappe/public/js/frappe/web_form/web_form.js index 1f540958df..a45fc941d3 100644 --- a/frappe/public/js/frappe/web_form/web_form.js +++ b/frappe/public/js/frappe/web_form/web_form.js @@ -160,17 +160,17 @@ export default class WebForm extends frappe.ui.FieldGroup { } setup_primary_action() { - this.add_button_to_header(this.button_label || "Save", "primary", () => + this.add_button_to_header(this.button_label || __("Save", null, "Button in web form"), "primary", () => this.save() ); - this.add_button_to_footer(this.button_label || "Save", "primary", () => + this.add_button_to_footer(this.button_label || __("Save", null, "Button in web form"), "primary", () => this.save() ); } setup_cancel_button() { - this.add_button_to_header(__("Cancel"), "light", () => this.cancel()); + this.add_button_to_header(__("Cancel", null, "Button in web form"), "light", () => this.cancel()); } setup_delete_button() { @@ -216,16 +216,18 @@ export default class WebForm extends frappe.ui.FieldGroup { let message = ''; if (invalid_values.length) { - message += __('Invalid values for fields:') + '

'; + message += __('Invalid values for fields:', null, 'Error message in web form'); + message += '

'; } if (errors.length) { - message += __('Mandatory fields required:') + '

'; + message += __('Mandatory fields required:', null, 'Error message in web form'); + message += '

'; } if (invalid_values.length || errors.length) { frappe.msgprint({ - title: __('Error'), + title: __('Error', null, 'Title of error message in web form'), message: message, indicator: 'orange' });