fix: Replace incorrect translation syntax usages

This commit is contained in:
Suraj Shetty 2020-10-11 22:08:22 +05:30
parent 7cfa4d59e9
commit a147e45d0c
14 changed files with 42 additions and 38 deletions

View file

@ -30,7 +30,7 @@ frappe.ui.form.on('Data Migration Connector', {
frm.set_value('connector_type', 'Custom');
frm.set_value('python_module', r.message);
frm.save();
frappe.show_alert(__(`New module created ${r.message}`));
frappe.show_alert(__("New module created {0}", [r.message]));
d.hide();
}
});

View file

@ -169,7 +169,7 @@ frappe.ui.form.on('Dashboard Chart', {
frm.field_options = frappe.report_utils.get_field_options_from_report(data.columns, data);
frm.set_df_property('x_field', 'options', frm.field_options.non_numeric_fields);
if (!frm.field_options.numeric_fields.length) {
frappe.msgprint(__(`Report has no numeric fields, please change the Report Name`));
frappe.msgprint(__("Report has no numeric fields, please change the Report Name"));
} else {
let y_field_df = frappe.meta.get_docfield('Dashboard Chart Field', 'y_field', frm.doc.name);
y_field_df.options = frm.field_options.numeric_fields;

View file

@ -207,7 +207,7 @@ frappe.ui.form.on('Number Card', {
frm.field_options = frappe.report_utils.get_field_options_from_report(data.columns, data);
frm.set_df_property('report_field', 'options', frm.field_options.numeric_fields);
if (!frm.field_options.numeric_fields.length) {
frappe.msgprint(__(`Report has no numeric fields, please change the Report Name`));
frappe.msgprint(__("Report has no numeric fields, please change the Report Name"));
}
} else {
frappe.msgprint(__('Report has no data, please modify the filters or change the Report Name'));

View file

@ -1,14 +1,12 @@
frappe.ui.form.ControlDynamicLink = frappe.ui.form.ControlLink.extend({
get_options: function() {
let options = '';
if(this.df.get_options) {
if (this.df.get_options) {
options = this.df.get_options();
}
else if (this.docname==null && cur_dialog) {
} else if (this.docname==null && cur_dialog) {
//for dialog box
options = cur_dialog.get_value(this.df.options);
}
else if (!cur_frm) {
} else if (!cur_frm) {
const selector = `input[data-fieldname="${this.df.options}"]`;
let input = null;
if (cur_list) {
@ -21,13 +19,12 @@ frappe.ui.form.ControlDynamicLink = frappe.ui.form.ControlLink.extend({
if (input) {
options = input.val();
}
}
else {
} else {
options = frappe.model.get_value(this.df.parent, this.docname, this.df.options);
}
if (frappe.model.is_single(options)) {
frappe.throw(__(`${options.bold()} is not a valid DocType for Dynamic Link`));
frappe.throw(__("{} is not a valid DocType for Dynamic Link", [options.bold()]));
}
return options;

View file

@ -78,7 +78,6 @@ frappe.ui.form.Review = class Review {
}
show_review_dialog() {
const user_options = this.get_involved_users();
const doc_owner = this.frm.doc.owner;
const review_dialog = new frappe.ui.Dialog({
'title': __('Add Review'),
'fields': [{
@ -106,7 +105,7 @@ frappe.ui.form.Review = class Review {
fieldtype: 'Int',
label: __('Points'),
reqd: 1,
description: __(`Currently you have ${this.points.review_points} review points`)
description: __("Currently you have {0} review points", [this.points.review_points])
}, {
fieldtype: 'Small Text',
fieldname: 'reason',
@ -181,7 +180,7 @@ frappe.ui.form.Review = class Review {
trigger: 'hover',
delay: 500,
placement: 'top',
template:`
template: `
<div class="review-popover popover">
<div class="arrow"></div>
<div class="popover-content"></div>

View file

@ -33,7 +33,7 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList {
if (!this.has_permissions()) {
frappe.set_route('');
frappe.msgprint(__(`Not permitted to view ${this.doctype}`));
frappe.msgprint(__("Not permitted to view {0}", [this.doctype]));
return;
}

View file

@ -54,7 +54,7 @@ frappe.ui.Filter = class {
this.filters_config = frappe.boot.additional_filters_config;
for (let key of Object.keys(this.filters_config)) {
const filter = this.filters_config[key];
this.conditions.push([key, __(`{0}`, [filter.label])]);
this.conditions.push([key, __("{0}", [filter.label])]);
for (let fieldtype of Object.keys(this.invalid_condition_map)) {
if (!filter.valid_for_fieldtypes.includes(fieldtype)) {
this.invalid_condition_map[fieldtype].push(key);
@ -542,13 +542,13 @@ frappe.ui.filter_utils = {
if (period_map[period]) {
period_map[period].forEach((p) => {
options.push({
label: __(`{0} {1}`, [period, p]),
label: __("{0} {1}", [period, p]),
value: `${period.toLowerCase()} ${p.toLowerCase()}`,
});
});
} else {
options.push({
label: __(`{0}`, [period]),
label: __("{0}", [period]),
value: `${period.toLowerCase()}`,
});
}

View file

@ -63,12 +63,11 @@ frappe.ui.FilterGroup = class {
}
validate_args(doctype, fieldname) {
if(doctype && fieldname
if (doctype && fieldname
&& !frappe.meta.has_field(doctype, fieldname)
&& !frappe.model.std_fields_list.includes(fieldname)) {
frappe.throw(__(`Invalid filter: "${[fieldname.bold()]}"`));
frappe.throw(__("Invalid filter: {0}", [fieldname.bold()]));
return false;
}
return true;

View file

@ -182,7 +182,7 @@ frappe.dashboard_utils = {
try {
f[3] = eval(f[3]);
} catch (e) {
frappe.throw(__(`Invalid expression set in filter ${f[1]} (${f[0]})`));
frappe.throw(__("Invalid expression set in filter {0} ({1})", [f[1], f[0]]));
}
});
filters = [...filters, ...dynamic_filters];
@ -192,7 +192,7 @@ frappe.dashboard_utils = {
const val = eval(dynamic_filters[key]);
dynamic_filters[key] = val;
} catch (e) {
frappe.throw(__(`Invalid expression set in filter ${key}`));
frappe.throw(__("Invalid expression set in filter {0}", [key]));
}
}
Object.assign(filters, dynamic_filters);
@ -238,7 +238,7 @@ frappe.dashboard_utils = {
let dashboard_route_html =
`<a href = "#dashboard/${values.dashboard}">${values.dashboard}</a>`;
let message =
__(`${doctype} ${values.name} added to Dashboard ` + dashboard_route_html);
__("{0} {1} added to Dashboard {2}", [doctype, values.name, dashboard_route_html]);
frappe.msgprint(message);
});

View file

@ -249,7 +249,7 @@ frappe.views.DashboardView = class DashboardView extends frappe.views.ListView {
show_add_chart_dialog() {
let fields = this.get_field_options();
const dialog = new frappe.ui.Dialog({
title: __(`Add a ${this.doctype} Chart`),
title: __("Add a {0} Chart", [this.doctype]),
fields: [
{
fieldname: 'new_or_existing',

View file

@ -306,7 +306,7 @@ class DesktopPage {
make_onboarding() {
this.onboarding_widget = frappe.widget.make_widget({
label: this.data.onboarding.label || __(`Let's Get Started`),
label: this.data.onboarding.label || __("Let's Get Started"),
subtitle: this.data.onboarding.subtitle,
steps: this.data.onboarding.items,
success: this.data.onboarding.success,
@ -371,7 +371,7 @@ class DesktopPage {
make_cards() {
let cards = new frappe.widget.WidgetGroup({
title: this.data.cards.label || __(`Reports & Masters`),
title: this.data.cards.label || __("Reports & Masters"),
container: this.page,
type: "links",
columns: 3,

View file

@ -322,12 +322,12 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList {
let message;
if (dashboard_name) {
let dashboard_route_html = `<a href = "#dashboard/${dashboard_name}">${dashboard_name}</a>`;
message = __(`New {0} {1} added to Dashboard ` + dashboard_route_html, [doctype, name]);
message = __("New {0} {1} added to Dashboard {2}", [doctype, name, dashboard_route_html]);
} else {
message = __(`New {0} {1} created`, [doctype, name]);
message = __("New {0} {1} created", [doctype, name]);
}
frappe.msgprint(message, __(`New {0} Created`, [doctype]));
frappe.msgprint(message, __("New {0} Created", [doctype]));
});
}
@ -433,7 +433,7 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList {
try {
out = eval(expression.substr(5));
} catch (e) {
frappe.throw(__(`Invalid "depends_on" expression set in filter ${filter_label}`));
frappe.throw(__('Invalid "depends_on" expression set in filter {0}', [filter_label]));
}
} else {
var value = doc[expression];
@ -738,14 +738,18 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList {
get_queued_prepared_reports_warning_message(reports) {
const route = `#List/Prepared Report/List?status=Queued&report_name=${this.report_name}`;
const report_link_html = reports.length == 1
? `<a class="underline" href="${route}">${__('1 Report')}</a>`
: `<a class="underline" href="${route}">${__("{0} Reports", [reports.length])}</a>`;
const no_of_reports_html = reports.length == 1
? `${__('There is ')}<a class="underline" href="${route}">${__('1 Report')}</a>`
: `${__('There are ')}<a class="underline" href="${route}">${__(`{} Reports`, [reports.length])}</a>`;
? `${__('There is {0} with the same filters already in the queue:', [report_link_html])}`
: `${__('There are {0} with the same filters already in the queue:', [report_link_html])}`;
let warning_message = `
<p>
${__(`Are you sure you want to generate a new report?
{} with the same filters already in the queue:`, [no_of_reports_html])}
${__("Are you sure you want to generate a new report?")}
${no_of_reports_html}
</p>`;
let get_item_html = item => `<a class="underline" href="#Form/Prepared Report/${item.name}">${item.name}</a>`;
@ -1013,7 +1017,7 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList {
field.value == values.x_field
)[0].label;
options.title = __(`${this.report_name}: ${x_field_label} vs ${y_field_label}`);
options.title = __("{0}: {1} vs {2}", [this.report_name, x_field_label, y_field_label]);
this.render_chart(options);
this.add_chart_buttons_to_toolbar(true);

View file

@ -387,7 +387,7 @@ export default class ChartWidget extends Widget {
setup_filter_dialog(fields) {
let me = this;
let dialog = new frappe.ui.Dialog({
title: __(`Set Filters for ${this.chart_doc.chart_name}`),
title: __("Set Filters for {0}", [this.chart_doc.chart_name]),
fields: fields,
primary_action: function() {
let values = this.get_values();

View file

@ -63,7 +63,12 @@ frappe.ui.form.on("Workflow", {
frm.save();
};
frappe.warn(__(`Worflow States Don't Exist`), message_html, proceed_action, __(`Save Anyway`));
frappe.warn(
__("Worflow States Don't Exist"),
message_html,
proceed_action,
__("Save Anyway")
);
},
set_table_html: function(frm) {