feat: translate desk
This commit is contained in:
parent
b7270d82ea
commit
9fb1c7b5b0
4 changed files with 39 additions and 18 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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. <b>Please relaod the page</b>. If the problem persists, contact the Administrator",
|
||||
__("Something went wrong while loading Desk. <b>Please relaod the page</b>. 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" : ""
|
||||
}">
|
||||
<span>${item.name}</span>
|
||||
<span>${item.label || item.name}</span>
|
||||
</div>`);
|
||||
};
|
||||
|
||||
|
|
@ -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 = $(
|
||||
`<div class="sidebar-group-title h6 uppercase">${name}</div>`
|
||||
`<div class="sidebar-group-title h6 uppercase">${__(name)}</div>`
|
||||
);
|
||||
$title.appendTo(this.sidebar);
|
||||
};
|
||||
|
|
@ -157,14 +159,14 @@ class DesktopPage {
|
|||
}
|
||||
|
||||
make_customization_link() {
|
||||
this.customize_link = $(`<div class="small customize-options" style="cursor: pointer;">Customize Workspace</div>`);
|
||||
this.customize_link = $(`<div class="small customize-options" style="cursor: pointer;">${__('Customize Workspace')}</div>`);
|
||||
this.customize_link.appendTo(this.page);
|
||||
this.customize_link.on('click', () => {
|
||||
this.customize();
|
||||
})
|
||||
|
||||
this.save_or_discard_link = $(`<div class="small customize-options small-bounce">
|
||||
<span class="save-customization">Save</span> / <span class="discard-customization">Discard</span>
|
||||
<span class="save-customization">${__('Save')}</span> / <span class="discard-customization">${__('Discard')}</span>
|
||||
</div>`).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,
|
||||
|
|
|
|||
|
|
@ -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)}`);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue