From 4e0571882e64689c1c2382ad6506137a8f139ded Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Fri, 14 Jun 2019 13:55:29 +0200 Subject: [PATCH] Sample Graphs report updates - Add the report to the Examples menu - Tweak strings and make them translatable - Rename report to better match the report title --- gnucash/report/reports/CMakeLists.txt | 1 + .../{test-graphing.scm => sample-graphs.scm} | 40 +++++++++---------- gnucash/report/reports/reports.scm | 2 - po/POTFILES.in | 1 + 4 files changed, 21 insertions(+), 23 deletions(-) rename gnucash/report/reports/example/{test-graphing.scm => sample-graphs.scm} (88%) diff --git a/gnucash/report/reports/CMakeLists.txt b/gnucash/report/reports/CMakeLists.txt index 469039e477..d7e81eb506 100644 --- a/gnucash/report/reports/CMakeLists.txt +++ b/gnucash/report/reports/CMakeLists.txt @@ -55,6 +55,7 @@ set(reports_example_SCHEME example/average-balance.scm example/daily-reports.scm example/hello-world.scm + example/sample-graphs.scm example/welcome-to-gnucash.scm ) diff --git a/gnucash/report/reports/example/test-graphing.scm b/gnucash/report/reports/example/sample-graphs.scm similarity index 88% rename from gnucash/report/reports/example/test-graphing.scm rename to gnucash/report/reports/example/sample-graphs.scm index 41463f1c2f..357af0bf66 100644 --- a/gnucash/report/reports/example/test-graphing.scm +++ b/gnucash/report/reports/example/sample-graphs.scm @@ -23,13 +23,23 @@ ;; It illustrates the basic techniques used to create ;; new reports for GnuCash. -(define-module (gnucash report reports example test-graphing)) +(define-module (gnucash report reports example sample-graphs)) (use-modules (gnucash utilities)) (use-modules (gnucash gnc-module)) +;; Add this module to enable translatable strings +;; Use (N_ string) to mark string for translation (it won't be translated on the spot) +;; Use (_ string) to use a translation of this string if it exists. +(use-modules (gnucash gettext)) + (gnc:module-load "gnucash/report/report-system" 0) (gnc:module-load "gnucash/gnome-utils" 0) ;for gnc-build-url +;; It's common to define frequently used strings once +;; This also helps getting more consistent messages which simplifies +;; the life of translators later on. +(define reportname (N_ "Sample Graphs")) + (define (simple-pie-chart) (let ((chart (gnc:make-html-chart))) ;; the minimum chartjs-based html-chart requires the following settings @@ -124,40 +134,28 @@ (let ((document (gnc:make-html-document))) - (gnc:html-document-set-title! document "Graphs") + (gnc:html-document-set-title! document (_ reportname)) (gnc:html-document-add-object! document - (gnc:make-html-text - (gnc:html-markup-p - (gnc:html-markup/format - "Sample graphs:")))) - - (gnc:html-document-add-object! - document - (gnc:make-html-text (gnc:html-markup-p "Pie:"))) + (gnc:make-html-text (gnc:html-markup-p (_ "Pie:")))) (gnc:html-document-add-object! document (simple-pie-chart)) (gnc:html-document-add-object! document - (gnc:make-html-text (gnc:html-markup-p "Bar, normal:"))) + (gnc:make-html-text (gnc:html-markup-p (_ "Bar, normal:")))) (gnc:html-document-add-object! document (simple-bar-chart #f)) (gnc:html-document-add-object! document - (gnc:make-html-text (gnc:html-markup-p "Bar, stacked:"))) + (gnc:make-html-text (gnc:html-markup-p (_ "Bar, stacked:")))) (gnc:html-document-add-object! document (simple-bar-chart #t)) (gnc:html-document-add-object! document - (gnc:make-html-text (gnc:html-markup-p "Scatter:"))) + (gnc:make-html-text (gnc:html-markup-p (_ "Scatter:")))) (gnc:html-document-add-object! document (simple-scatter-chart)) - (gnc:html-document-add-object! - document - (gnc:make-html-text - (gnc:html-markup-p "Done."))) - document)) ;; Here we define the actual report with gnc:define-report @@ -169,7 +167,7 @@ ;; The name of this report. This will be used, among other things, ;; for making its menu item in the main menu. You need to use the ;; untranslated value here! - 'name "Test Graphing" + 'name reportname ;; The GUID for this report. This string should be unique, set once ;; and left alone forever after that. In theory, you could use any @@ -180,11 +178,11 @@ ;; The name in the menu ;; (only necessary if it differs from the name) - 'menu-name "Sample graphs" + 'menu-name (_ reportname) ;; A tip that is used to provide additional information about the ;; report to the user. - 'menu-tip "Sample graphs" + 'menu-tip (_ reportname) ;; A path describing where to put the report in the menu system. ;; In this case, it's going under the utility menu. diff --git a/gnucash/report/reports/reports.scm b/gnucash/report/reports/reports.scm index 8d87b64118..a96cbc5ecc 100644 --- a/gnucash/report/reports/reports.scm +++ b/gnucash/report/reports/reports.scm @@ -97,8 +97,6 @@ (get-report-list rpt-dir-str))) report-dirs) -;;(use-modules (gnucash report test-graphing)) - (use-modules (gnucash gnc-module)) (gnc:module-load "gnucash/engine" 0) diff --git a/po/POTFILES.in b/po/POTFILES.in index 157509e17d..e244701ec0 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -427,6 +427,7 @@ gnucash/report/reports/aging.scm gnucash/report/reports/example/average-balance.scm gnucash/report/reports/example/daily-reports.scm gnucash/report/reports/example/hello-world.scm +gnucash/report/reports/example/sample-graphs.scm gnucash/report/reports/example/welcome-to-gnucash.scm gnucash/report/reports/reports.scm gnucash/report/reports/standard/account-piecharts.scm