Просмотр исходного кода

chore: add translation context to strings(#15649)

* chore: add translation context

* revert: changes to some translatable strings

This way existing translations will continue to work until the translation process is improved.

* style: sider
version-14
Raffael Meyer 3 лет назад
committed by GitHub
Родитель
Сommit
d49199876a
Не найден GPG ключ соответствующий данной подписи Идентификатор GPG ключа: 4AEE18F83AFDEB23
7 измененных файлов: 70 добавлений и 56 удалений
  1. +3
    -2
      frappe/public/js/frappe/desk.js
  2. +4
    -1
      frappe/public/js/frappe/form/form.js
  3. +8
    -9
      frappe/public/js/frappe/form/save.js
  4. +42
    -35
      frappe/public/js/frappe/list/list_view.js
  5. +4
    -2
      frappe/public/js/frappe/ui/dialog.js
  6. +1
    -1
      frappe/public/js/frappe/ui/messages.js
  7. +8
    -6
      frappe/public/js/frappe/web_form/web_form.js

+ 3
- 2
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: <b>{0}</b>', [email_account[i]["email_id"]]),
'label': __('Please enter the password for: <b>{0}</b>', [email_id], "Email Account"),
'reqd': 1
},
{
"fieldname": "submit",
"fieldtype": "Button",
"label": __("Submit")
"label": __("Submit", null, "Submit password for Email Account")
}
]
});


+ 4
- 1
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")
);
}
}



+ 8
- 9
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;
}
}


+ 42
- 35
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 = $(
`<div class="freeze flex justify-center align-center text-muted">${__(
"Loading"
)}...</div>`
`<div class="freeze flex justify-center align-center text-muted">
${__("Loading")}...
</div>`
).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
? `<p><button class="btn btn-primary btn-sm btn-new-doc hidden-xs">
${new_button_label}
</button> <button class="btn btn-primary btn-new-doc visible-xs">${__('Create New')}</button></p>`
</button> <button class="btn btn-primary btn-new-doc visible-xs">
${__("Create New", null, "Create a new document from list view")}
</button></p>`
: "";

return `<div class="msg-box no-border">
@@ -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(`<span>${__("Refreshing")}...</span>`);
.html(`<span>${__("Refreshing", null, "Document count in list view")}...</span>`);
}
}

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



+ 4
- 2
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) {


+ 1
- 1
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
});


+ 8
- 6
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:') + '<br><br><ul><li>' + invalid_values.join('<li>') + '</ul>';
message += __('Invalid values for fields:', null, 'Error message in web form');
message += '<br><br><ul><li>' + invalid_values.join('<li>') + '</ul>';
}

if (errors.length) {
message += __('Mandatory fields required:') + '<br><br><ul><li>' + errors.join('<li>') + '</ul>';
message += __('Mandatory fields required:', null, 'Error message in web form');
message += '<br><br><ul><li>' + errors.join('<li>') + '</ul>';
}

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


Загрузка…
Отмена
Сохранить