From c8c77437fa70080a14ac22bcfce92f696ac041bb Mon Sep 17 00:00:00 2001 From: hrwx Date: Thu, 6 Jan 2022 12:02:24 +0530 Subject: [PATCH] feat: add translations to datatable --- frappe/public/js/desk.bundle.js | 1 + .../js/frappe/data_import/import_preview.js | 2 ++ frappe/public/js/frappe/utils/datatable.js | 22 +++++++++++++++++++ .../js/frappe/views/reports/query_report.js | 4 +++- .../js/frappe/views/reports/report_view.js | 2 ++ 5 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 frappe/public/js/frappe/utils/datatable.js diff --git a/frappe/public/js/desk.bundle.js b/frappe/public/js/desk.bundle.js index 99b644a5c7..cac02c7a68 100644 --- a/frappe/public/js/desk.bundle.js +++ b/frappe/public/js/desk.bundle.js @@ -63,6 +63,7 @@ import "./frappe/utils/address_and_contact.js"; import "./frappe/utils/preview_email.js"; import "./frappe/utils/file_manager.js"; import "./frappe/utils/diffview"; +import "./frappe/utils/datatable.js"; import "./frappe/upload.js"; import "./frappe/ui/tree.js"; diff --git a/frappe/public/js/frappe/data_import/import_preview.js b/frappe/public/js/frappe/data_import/import_preview.js index 75bfb90bde..2264042539 100644 --- a/frappe/public/js/frappe/data_import/import_preview.js +++ b/frappe/public/js/frappe/data_import/import_preview.js @@ -142,6 +142,8 @@ frappe.data_import.ImportPreview = class ImportPreview { columns: this.columns, layout: this.columns.length < 10 ? 'fluid' : 'fixed', cellHeight: 35, + language: frappe.boot.lang, + translations: frappe.utils.datatable.get_translations(), serialNoColumn: false, checkboxColumn: false, noDataMessage: __('No Data'), diff --git a/frappe/public/js/frappe/utils/datatable.js b/frappe/public/js/frappe/utils/datatable.js new file mode 100644 index 0000000000..e07b86df94 --- /dev/null +++ b/frappe/public/js/frappe/utils/datatable.js @@ -0,0 +1,22 @@ +frappe.provide("frappe.utils.datatable"); + +frappe.utils.datatable.get_translations = function () { + let translations = {}; + translations[frappe.boot.lang] = { + "Sort Ascending": __("Sort Ascending"), + "Sort Descending": __("Sort Descending"), + "Reset sorting": __("Reset sorting"), + "Remove column": __("Remove column"), + "No Data": __("No Data"), + "{count} cells copied": { + "1": __("{count} cell copied"), + "default": __("{count} cells copied") + }, + "{count} rows selected": { + "1": __("{count} row selected"), + "default": __("{count} rows selected") + } + }; + + return translations; +} \ No newline at end of file diff --git a/frappe/public/js/frappe/views/reports/query_report.js b/frappe/public/js/frappe/views/reports/query_report.js index 920a252b56..7ba0a0228f 100644 --- a/frappe/public/js/frappe/views/reports/query_report.js +++ b/frappe/public/js/frappe/views/reports/query_report.js @@ -105,7 +105,7 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList { this.toggle_nothing_to_show(true); return; } - + let route_options = {}; route_options = Object.assign(route_options, frappe.route_options); @@ -849,6 +849,8 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList { columns: columns, data: data, inlineFilters: true, + language: frappe.boot.lang, + translations: frappe.utils.datatable.get_translations(), treeView: this.tree_report, layout: 'fixed', cellHeight: 33, diff --git a/frappe/public/js/frappe/views/reports/report_view.js b/frappe/public/js/frappe/views/reports/report_view.js index c70c64be0e..6d8e281793 100644 --- a/frappe/public/js/frappe/views/reports/report_view.js +++ b/frappe/public/js/frappe/views/reports/report_view.js @@ -284,6 +284,8 @@ frappe.views.ReportView = class ReportView extends frappe.views.ListView { columns: this.columns, data: this.get_data(values), getEditor: this.get_editing_object.bind(this), + language: frappe.boot.lang, + translations: frappe.utils.datatable.get_translations(), checkboxColumn: true, inlineFilters: true, cellHeight: 35,