diff --git a/frappe/desk/desktop.py b/frappe/desk/desktop.py index b616c2838d..7041704513 100644 --- a/frappe/desk/desktop.py +++ b/frappe/desk/desktop.py @@ -77,17 +77,17 @@ class Workspace: def build_workspace(self): self.cards = { - 'label': self.doc.cards_label, + 'label': _(self.doc.cards_label), 'items': self.get_cards() } self.charts = { - 'label': self.doc.charts_label, + 'label': _(self.doc.charts_label), 'items': self.get_charts() } self.shortcuts = { - 'label': self.doc.shortcuts_label, + 'label': _(self.doc.charts_label), 'items': self.get_shortcuts() } @@ -121,6 +121,9 @@ class Workspace: item["count"] = count + # Translate label + item["label"] = _(item.label) if item.label else _(item.name) + return item new_data = [] @@ -141,7 +144,7 @@ class Workspace: # Check if user is allowed to view if self.is_item_allowed(item.name, item.type): prepared_item = _prepare_item(item) - new_items.append(item) + new_items.append(prepared_item) if new_items: if isinstance(section, frappe._dict): @@ -149,6 +152,7 @@ class Workspace: else: new_section = section.as_dict().copy() new_section["links"] = new_items + new_section["label"] = _(new_section["label"]) new_data.append(new_section) return new_data @@ -162,7 +166,8 @@ class Workspace: for chart in charts: if frappe.has_permission('Dashboard Chart', doc=chart.chart_name): - chart.label = chart.label if chart.label else chart.chart_name + # Translate label + chart.label = _(chart.label) if chart.label else _(chart.chart_name) all_charts.append(chart) return all_charts @@ -185,12 +190,14 @@ class Workspace: if self.is_item_allowed(item.link_to, item.type) and _in_active_domains(item): if item.type == "Page": page = self.allowed_pages[item.link_to] - new_item['label'] = _(page.get("title", frappe.unscrub(item.link_to))) if item.type == "Report": report = self.allowed_reports.get(item.link_to, {}) if report.get("report_type") in ["Query Report", "Script Report"]: new_item['is_query_report'] = 1 + # Translate label + new_item["label"] = _(item.label) if item.label else _(item.link_to) + items.append(new_item) return items @@ -247,8 +254,11 @@ def get_desk_sidebar_items(): from collections import defaultdict sidebar_items = defaultdict(list) + # The order will be maintained while categorizing for page in pages: - # The order will be maintained while categorizing + # Translate label + page['label'] = _(page.get('name')) + print(page) sidebar_items[page["category"]].append(page) return sidebar_items diff --git a/frappe/public/js/frappe/views/desktop/desktop.js b/frappe/public/js/frappe/views/desktop/desktop.js index e0f400ed9a..742f769b79 100644 --- a/frappe/public/js/frappe/views/desktop/desktop.js +++ b/frappe/public/js/frappe/views/desktop/desktop.js @@ -44,12 +44,12 @@ export default class Desktop { this.desktop_settings = response.message; } else { frappe.throw({ - title: "Couldn't Load Desk", + title: __("Couldn't Load Desk"), message: - "Something went wrong while loading Desk. Please relaod the page. If the problem persists, contact the Administrator", + __("Something went wrong while loading Desk. Please relaod the page. If the problem persists, contact the Administrator"), indicator: "red", primary_action: { - label: "Reload", + label: __("Reload"), action: () => location.reload() } }); @@ -63,7 +63,7 @@ export default class Desktop { item.name}" class="sidebar-item ${ item.selected ? "selected" : "" }"> - ${item.name} + ${item.label || item.name} `); }; @@ -78,8 +78,10 @@ export default class Desktop { }; const make_category_title = name => { + // DO NOT REMOVE: Comment to load translation + // __("Modules") __("Domains") __("Places") __("Administration") let $title = $( - `` + `` ); $title.appendTo(this.sidebar); }; @@ -157,14 +159,14 @@ class DesktopPage { } make_customization_link() { - this.customize_link = $(`
Customize Workspace
`); + this.customize_link = $(`
${__('Customize Workspace')}
`); this.customize_link.appendTo(this.page); this.customize_link.on('click', () => { this.customize(); }) this.save_or_discard_link = $(`
- Save / Discard + ${__('Save')} / ${__('Discard')}
`).hide(); this.save_or_discard_link.appendTo(this.page); @@ -272,7 +274,7 @@ class DesktopPage { } this.sections["charts"] = new frappe.widget.WidgetGroup({ - title: this.data.charts.label || `${this.page_name} Dashboard`, + title: this.data.charts.label || __('{} Dashboard', [__(this.page_name)]), container: this.page, type: "chart", columns: 1, @@ -291,7 +293,7 @@ class DesktopPage { make_shortcuts() { this.sections["shortcuts"] = new frappe.widget.WidgetGroup({ - title: this.data.shortcuts.label || `Your Shortcuts`, + title: this.data.shortcuts.label || __(`Your Shortcuts`), container: this.page, type: "shortcut", columns: 3, @@ -308,7 +310,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, diff --git a/frappe/public/js/frappe/widgets/new_widget.js b/frappe/public/js/frappe/widgets/new_widget.js index ffd96c87da..787cb3a79c 100644 --- a/frappe/public/js/frappe/widgets/new_widget.js +++ b/frappe/public/js/frappe/widgets/new_widget.js @@ -17,6 +17,8 @@ export default class NewWidget { } get_title() { + // DO NOT REMOVE: Comment to load translation + // __("New Chart") __("New Shortcut") return __(`New ${frappe.utils.to_title_case(this.type)}`); } diff --git a/frappe/public/js/frappe/widgets/widget_dialog.js b/frappe/public/js/frappe/widgets/widget_dialog.js index 1584c59ed4..c04d0209f9 100644 --- a/frappe/public/js/frappe/widgets/widget_dialog.js +++ b/frappe/public/js/frappe/widgets/widget_dialog.js @@ -34,7 +34,14 @@ class WidgetDialog { } get_title() { - return __(`New ${frappe.utils.to_title_case(this.type)}`); + // DO NOT REMOVE: Comment to load translation + // __("New Chart") __("New Shortcut") __("Edit Chart") __("Edit Shortcut") + + if (this.values && Object.keys(this.values).length) { + return __(`Edit ${frappe.utils.to_title_case(this.type)}`); + } else { + return __(`Add ${frappe.utils.to_title_case(this.type)}`); + } } get_fields() {