From 41dc6ddbe2186eaed476e725d6cb1a0ed7207bf8 Mon Sep 17 00:00:00 2001 From: c-holtermann Date: Sat, 29 Feb 2020 16:16:05 +0100 Subject: [PATCH 01/16] implement gettext localization for python make gnc_path_get_localedir() and GETTEXT_PACKAGE available for python to access locales. Import gettext module to provide _ as translator method. Provide null _-method returning english text in case of missing gettext. Make a lot of messages translatable by adding _-method. Include python files to create .pot-files. --- bindings/core-utils.i | 6 ++++++ bindings/python/gnucash_core.py | 21 ++++++++++++++++++++- gnucash/python/init.py | 6 ++++++ po/CMakeLists.txt | 2 +- 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/bindings/core-utils.i b/bindings/core-utils.i index c869770673..f66a184e80 100644 --- a/bindings/core-utils.i +++ b/bindings/core-utils.i @@ -57,6 +57,12 @@ gchar * gnc_path_get_scmdir(void); %newobject gnc_path_get_reportsdir; gchar * gnc_path_get_reportsdir(void); +%newobject gnc_path_get_localedir; +gchar * gnc_path_get_localedir(void); + +/* Name of our gettext-domain (defined in config.h) */ +%constant char* GETTEXT_PACKAGE = GETTEXT_PACKAGE; + %newobject gnc_path_get_stdreportsdir; gchar * gnc_path_get_stdreportsdir(void); diff --git a/bindings/python/gnucash_core.py b/bindings/python/gnucash_core.py index 6302fba46d..a660c6afb0 100644 --- a/bindings/python/gnucash_core.py +++ b/bindings/python/gnucash_core.py @@ -28,7 +28,8 @@ # @author Jeff Green, ParIT Worker Co-operative # @ingroup python_bindings -import gnucash.gnucash_core_c as gnucash_core_c +from gnucash import gnucash_core_c +from gnucash import _sw_core_utils from gnucash.function_class import \ ClassFromFunctions, extract_attributes_with_prefix, \ @@ -46,6 +47,24 @@ from gnucash.gnucash_core_c import gncInvoiceLookup, gncInvoiceGetInvoiceFromTxn gnc_numeric_create, double_to_gnc_numeric, string_to_gnc_numeric, \ gnc_numeric_to_string +try: + import gettext + # install gettext for _-function, needs path to locales + _localedir = _sw_core_utils.gnc_path_get_localedir() + _translation = gettext.translation(_sw_core_utils.GETTEXT_PACKAGE, _localedir) + _ = _translation.gettext +except: + print("\nProblem importing gettext!") + import traceback + import sys + exc_type, exc_value, exc_traceback = sys.exc_info() + traceback.print_exception(exc_type, exc_value, exc_traceback) + print() + + def _(s): + """Null translator function, gettext not available""" + return s + class GnuCashCoreClass(ClassFromFunctions): _module = gnucash_core_c diff --git a/gnucash/python/init.py b/gnucash/python/init.py index bfc319ad5c..c364b2dd4e 100644 --- a/gnucash/python/init.py +++ b/gnucash/python/init.py @@ -1,16 +1,22 @@ import sys from gnucash import * +from gnucash import _sw_app_utils +from gnucash import _sw_core_utils from gnucash._sw_core_utils import gnc_prefs_is_extra_enabled, gnc_prefs_is_debugging_enabled +from gnucash.gnucash_core import _ from gi import require_version require_version('Gtk', '3.0') from gi.repository import Gtk import os + sys.path.append(os.path.dirname(__file__)) # output file location if gnucash has been started with # gnucash --extra if gnc_prefs_is_extra_enabled(): print("Python shell init file: %s" % (__file__)) + print("\n" + "The following string should appear translated in your preferred language:" + "\n") + print("\n" + _("Welcome to GnuCash") +"\n") # Importing the console class causes SIGTTOU to be thrown if GnuCash is # started in the background. This causes a hang if it is not handled, diff --git a/po/CMakeLists.txt b/po/CMakeLists.txt index 5c4cbaefa0..51180baa0e 100644 --- a/po/CMakeLists.txt +++ b/po/CMakeLists.txt @@ -75,7 +75,7 @@ function(make_gnucash_potfiles) ${CMAKE_SOURCE_DIR}/*.glade ${CMAKE_SOURCE_DIR}/*.desktop.in.in ${CMAKE_SOURCE_DIR}/*.gschema.xml.in ${CMAKE_SOURCE_DIR}/*.appdata.xml.in.in ${CMAKE_SOURCE_DIR}/*.keys.in ${CMAKE_SOURCE_DIR}/*.scm - ${CMAKE_SOURCE_DIR}/*/qofbookslots.h + ${CMAKE_SOURCE_DIR}/*.py ${CMAKE_SOURCE_DIR}/*/qofbookslots.h ${CMAKE_SOURCE_DIR}/*/gnc-commodity.h ) From 22848c6b0aeb8c5527b2f51e762fa64c42653929 Mon Sep 17 00:00:00 2001 From: c-holtermann Date: Sat, 29 Feb 2020 15:51:07 +0100 Subject: [PATCH 02/16] localize strings for python --- gnucash/python/init.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/gnucash/python/init.py b/gnucash/python/init.py index c364b2dd4e..81a38b388d 100644 --- a/gnucash/python/init.py +++ b/gnucash/python/init.py @@ -101,7 +101,7 @@ class Console (cons.Console): def quit (self): """ quit """ - self.write("\nHave a nice day !\n") + self.write("\n" + _("Have a nice day!") + "\n") return super(Console, self).quit() @@ -110,9 +110,14 @@ class Console (cons.Console): # shelltype can either be "python" or "ipython" (the latter is not yet fully functional) if False: shelltype = "python" - title = "gnucash "+shelltype+" shell" + if shelltype=="python": + shelltypeName = "Python" + else: + shelltypeName = "IPython" banner_style = 'title' - banner = "Welcome to "+title+"!\n" + # TRANSLATORS: %s is either Python or IPython + banner = _("Welcome to GnuCash %s Shell") % shelltypeName + console = Console(argv = [], shelltype = shelltype, banner = [[banner, banner_style]], size = 100) window = Gtk.Window(type = Gtk.WindowType.TOPLEVEL) window.set_position(Gtk.WindowPosition.CENTER) From 101a2ca09d3881eb13d97606fc49955a137d0cfc Mon Sep 17 00:00:00 2001 From: c-holtermann Date: Sun, 1 Mar 2020 08:14:28 +0100 Subject: [PATCH 03/16] add translatable python files --- po/POTFILES.in | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/po/POTFILES.in b/po/POTFILES.in index 6041f220f1..0f28d6a784 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -12,6 +12,27 @@ bindings/guile/gnc-kvp-guile.cpp bindings/guile/gnc-module.scm bindings/guile/gnc-numeric.scm bindings/guile/utilities.scm +bindings/python/example_scripts/account_analysis.py +bindings/python/example_scripts/change_tax_code.py +bindings/python/example_scripts/gnc_convenience.py +bindings/python/example_scripts/gncinvoicefkt.py +bindings/python/example_scripts/gncinvoice_jinja.py +bindings/python/example_scripts/latex_invoices.py +bindings/python/example_scripts/new_book_with_opening_balances.py +bindings/python/example_scripts/price_database_example.py +bindings/python/example_scripts/quotes_historic.py +bindings/python/example_scripts/rest-api/gnucash_rest.py +bindings/python/example_scripts/rest-api/gnucash_simple.py +bindings/python/example_scripts/simple_book.py +bindings/python/example_scripts/simple_business_create.py +bindings/python/example_scripts/simple_invoice_insert.py +bindings/python/example_scripts/simple_session.py +bindings/python/example_scripts/simple_sqlite_create.py +bindings/python/example_scripts/str_methods.py +bindings/python/function_class.py +bindings/python/gnucash_business.py +bindings/python/gnucash_core.py +bindings/python/__init__.py borrowed/goffice/go-charmap-sel.c borrowed/goffice/go-glib-extras.c borrowed/goffice/go-optionmenu.c @@ -350,6 +371,13 @@ gnucash/import-export/qif-imp/qif-utils.scm gnucash/import-export/qif-imp/string.scm gnucash/price-quotes.scm gnucash/python/gncmod-python.c +gnucash/python/init.py +gnucash/python/pycons/console.py +gnucash/python/pycons/__init__.py +gnucash/python/pycons/ishell.py +gnucash/python/pycons/setup.py +gnucash/python/pycons/shell.py +gnucash/python/pycons/simple_plot.py gnucash/register/ledger-core/gncEntryLedger.c gnucash/register/ledger-core/gncEntryLedgerControl.c gnucash/register/ledger-core/gncEntryLedgerDisplay.c @@ -582,6 +610,7 @@ libgnucash/core-utils/gnc-path.c libgnucash/core-utils/gnc-prefs.c libgnucash/core-utils/gnc-version.c libgnucash/doc/doxygen_main_page.c +libgnucash/doc/python-bindings-doxygen.py libgnucash/engine/Account.cpp libgnucash/engine/cap-gains.c libgnucash/engine/cashobjects.c From 31d2b3cb44ad92fd1575e9945da7c4debc7866f6 Mon Sep 17 00:00:00 2001 From: c-holtermann Date: Fri, 10 Apr 2020 18:16:50 +0200 Subject: [PATCH 04/16] install gettext --- bindings/python/gnucash_core.py | 14 +++++++++++--- gnucash/python/init.py | 1 - 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/bindings/python/gnucash_core.py b/bindings/python/gnucash_core.py index a660c6afb0..bc118d4259 100644 --- a/bindings/python/gnucash_core.py +++ b/bindings/python/gnucash_core.py @@ -49,10 +49,10 @@ from gnucash.gnucash_core_c import gncInvoiceLookup, gncInvoiceGetInvoiceFromTxn try: import gettext - # install gettext for _-function, needs path to locales + import locale + _localedir = _sw_core_utils.gnc_path_get_localedir() - _translation = gettext.translation(_sw_core_utils.GETTEXT_PACKAGE, _localedir) - _ = _translation.gettext + gettext.install(_sw_core_utils.GETTEXT_PACKAGE, _localedir) except: print("\nProblem importing gettext!") import traceback @@ -60,11 +60,19 @@ except: exc_type, exc_value, exc_traceback = sys.exc_info() traceback.print_exception(exc_type, exc_value, exc_traceback) print() + import locale + sys_locale = locale.setlocale(locale.LC_ALL, '') + print("locale: ", sys_locale) + print("getlocale(): " + str(locale.getlocale())) + print("localedir: " + _localedir) def _(s): """Null translator function, gettext not available""" return s + import builtins + builtins.__dict__['_'] = _ + class GnuCashCoreClass(ClassFromFunctions): _module = gnucash_core_c diff --git a/gnucash/python/init.py b/gnucash/python/init.py index 81a38b388d..c042b6d26f 100644 --- a/gnucash/python/init.py +++ b/gnucash/python/init.py @@ -3,7 +3,6 @@ from gnucash import * from gnucash import _sw_app_utils from gnucash import _sw_core_utils from gnucash._sw_core_utils import gnc_prefs_is_extra_enabled, gnc_prefs_is_debugging_enabled -from gnucash.gnucash_core import _ from gi import require_version require_version('Gtk', '3.0') from gi.repository import Gtk From 694e5a26ff312f841ad9eceb9f75b20099d6966a Mon Sep 17 00:00:00 2001 From: c-holtermann Date: Wed, 8 Apr 2020 07:33:15 +0200 Subject: [PATCH 05/16] add test for gettext --- bindings/python/tests/CMakeLists.txt | 1 + bindings/python/tests/runTests.py.in | 1 + bindings/python/tests/test_gettext.py | 22 ++++++++++++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 bindings/python/tests/test_gettext.py diff --git a/bindings/python/tests/CMakeLists.txt b/bindings/python/tests/CMakeLists.txt index dca317de43..e118e5a6cb 100644 --- a/bindings/python/tests/CMakeLists.txt +++ b/bindings/python/tests/CMakeLists.txt @@ -16,6 +16,7 @@ endif() set(test_python_bindings_DATA runTests.py.in + test_gettext.py test_account.py test_book.py test_business.py diff --git a/bindings/python/tests/runTests.py.in b/bindings/python/tests/runTests.py.in index 4e6ccc4e30..8f88d8eb68 100755 --- a/bindings/python/tests/runTests.py.in +++ b/bindings/python/tests/runTests.py.in @@ -5,6 +5,7 @@ import os os.environ["GNC_UNINSTALLED"] = "1" +from test_gettext import TestGettext from test_session import TestSession from test_book import TestBook from test_account import TestAccount diff --git a/bindings/python/tests/test_gettext.py b/bindings/python/tests/test_gettext.py new file mode 100644 index 0000000000..1e53a86ed5 --- /dev/null +++ b/bindings/python/tests/test_gettext.py @@ -0,0 +1,22 @@ +# test gettext +# +# @date 2020-04-08 +# @author Christoph Holtermann + +from unittest import TestCase, main +import gettext +import gnucash +from gnucash import _sw_core_utils + +class TestGettext(TestCase): + def test_import_gettext(self): + import gettext + + def test_get_localedir(self): + _localedir = _sw_core_utils.gnc_path_get_localedir() + + def test_translation(self): + self.assertTrue("Project-Id-Version: GnuCash" in _("")) + +if __name__ == '__main__': + main() From 2c09fe4f44fa928112439f0123779df1546a25a9 Mon Sep 17 00:00:00 2001 From: c-holtermann Date: Mon, 27 Apr 2020 22:08:15 +0200 Subject: [PATCH 06/16] debug on travis --- bindings/python/tests/test_gettext.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bindings/python/tests/test_gettext.py b/bindings/python/tests/test_gettext.py index 1e53a86ed5..9565c631b2 100644 --- a/bindings/python/tests/test_gettext.py +++ b/bindings/python/tests/test_gettext.py @@ -8,6 +8,9 @@ import gettext import gnucash from gnucash import _sw_core_utils +class MyException(Exception): + pass + class TestGettext(TestCase): def test_import_gettext(self): import gettext @@ -16,6 +19,7 @@ class TestGettext(TestCase): _localedir = _sw_core_utils.gnc_path_get_localedir() def test_translation(self): + raise MyException({'_(""): ':_(""), '_sw_core_utils.gnc_path_get_localedir(): ':_sw_core_utils.gnc_path_get_localedir()}) self.assertTrue("Project-Id-Version: GnuCash" in _("")) if __name__ == '__main__': From 8d429d82956ee056f381d8af964b820a33205d5e Mon Sep 17 00:00:00 2001 From: c-holtermann Date: Tue, 28 Apr 2020 18:41:43 +0200 Subject: [PATCH 07/16] further debugging --- bindings/python/tests/test_gettext.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bindings/python/tests/test_gettext.py b/bindings/python/tests/test_gettext.py index 9565c631b2..e69a6f8b91 100644 --- a/bindings/python/tests/test_gettext.py +++ b/bindings/python/tests/test_gettext.py @@ -19,7 +19,8 @@ class TestGettext(TestCase): _localedir = _sw_core_utils.gnc_path_get_localedir() def test_translation(self): - raise MyException({'_(""): ':_(""), '_sw_core_utils.gnc_path_get_localedir(): ':_sw_core_utils.gnc_path_get_localedir()}) + import inspect + raise MyException({'_(""): ':_(""), '_sw_core_utils.gnc_path_get_localedir(): ':_sw_core_utils.gnc_path_get_localedir(),'_.__doc__': _.__doc__, 'inspect: ': inspect.getsource(_)}) self.assertTrue("Project-Id-Version: GnuCash" in _("")) if __name__ == '__main__': From fc87e275faab37f3af3329c5d3e119426fd3c689 Mon Sep 17 00:00:00 2001 From: c-holtermann Date: Tue, 28 Apr 2020 19:09:42 +0200 Subject: [PATCH 08/16] further debugging --- bindings/python/tests/test_gettext.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bindings/python/tests/test_gettext.py b/bindings/python/tests/test_gettext.py index e69a6f8b91..7a81d5e64e 100644 --- a/bindings/python/tests/test_gettext.py +++ b/bindings/python/tests/test_gettext.py @@ -20,7 +20,8 @@ class TestGettext(TestCase): def test_translation(self): import inspect - raise MyException({'_(""): ':_(""), '_sw_core_utils.gnc_path_get_localedir(): ':_sw_core_utils.gnc_path_get_localedir(),'_.__doc__': _.__doc__, 'inspect: ': inspect.getsource(_)}) + import locale + raise MyException({'_(""): ':_(""), '_sw_core_utils.gnc_path_get_localedir(): ':_sw_core_utils.gnc_path_get_localedir(),'_.__doc__': _.__doc__, 'inspect.getsource(_): ': inspect.getsource(_), '_("Welcome to GnuCash")':_("Welcome to GnuCash"), 'locale.getlocale(): ': locale.getlocale()}) self.assertTrue("Project-Id-Version: GnuCash" in _("")) if __name__ == '__main__': From f788e593185ef3bcf460c330ac81bfe200bd8aba Mon Sep 17 00:00:00 2001 From: c-holtermann Date: Tue, 28 Apr 2020 20:57:58 +0200 Subject: [PATCH 09/16] remove debug stuff (temporarily) --- bindings/python/tests/test_gettext.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bindings/python/tests/test_gettext.py b/bindings/python/tests/test_gettext.py index 7a81d5e64e..fd56fa5a37 100644 --- a/bindings/python/tests/test_gettext.py +++ b/bindings/python/tests/test_gettext.py @@ -4,7 +4,7 @@ # @author Christoph Holtermann from unittest import TestCase, main -import gettext +# import gettext import gnucash from gnucash import _sw_core_utils @@ -18,11 +18,11 @@ class TestGettext(TestCase): def test_get_localedir(self): _localedir = _sw_core_utils.gnc_path_get_localedir() - def test_translation(self): - import inspect - import locale - raise MyException({'_(""): ':_(""), '_sw_core_utils.gnc_path_get_localedir(): ':_sw_core_utils.gnc_path_get_localedir(),'_.__doc__': _.__doc__, 'inspect.getsource(_): ': inspect.getsource(_), '_("Welcome to GnuCash")':_("Welcome to GnuCash"), 'locale.getlocale(): ': locale.getlocale()}) - self.assertTrue("Project-Id-Version: GnuCash" in _("")) + #def test_translation(self): + # import inspect + # import locale + # raise MyException({'_(""): ':_(""), '_sw_core_utils.gnc_path_get_localedir(): ':_sw_core_utils.gnc_path_get_localedir(),'_.__doc__': _.__doc__, 'inspect.getsource(_): ': inspect.getsource(_), '_("Welcome to GnuCash")':_("Welcome to GnuCash"), 'locale.getlocale(): ': locale.getlocale()}) + # self.assertTrue("Project-Id-Version: GnuCash" in _("")) if __name__ == '__main__': main() From efe9b4b606f72e92082507e47eb47e98b8e4381c Mon Sep 17 00:00:00 2001 From: c-holtermann Date: Thu, 28 May 2020 20:19:39 +0200 Subject: [PATCH 10/16] remove debug info --- bindings/python/gnucash_core.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/bindings/python/gnucash_core.py b/bindings/python/gnucash_core.py index bc118d4259..ffa4864b95 100644 --- a/bindings/python/gnucash_core.py +++ b/bindings/python/gnucash_core.py @@ -54,17 +54,13 @@ try: _localedir = _sw_core_utils.gnc_path_get_localedir() gettext.install(_sw_core_utils.GETTEXT_PACKAGE, _localedir) except: - print("\nProblem importing gettext!") + print() + print("Problem importing gettext!") import traceback import sys exc_type, exc_value, exc_traceback = sys.exc_info() traceback.print_exception(exc_type, exc_value, exc_traceback) print() - import locale - sys_locale = locale.setlocale(locale.LC_ALL, '') - print("locale: ", sys_locale) - print("getlocale(): " + str(locale.getlocale())) - print("localedir: " + _localedir) def _(s): """Null translator function, gettext not available""" From ca21f3224935c2b73b23a977c84dc0c8c208b2a3 Mon Sep 17 00:00:00 2001 From: c-holtermann Date: Thu, 28 May 2020 20:21:31 +0200 Subject: [PATCH 11/16] remove global gettext import --- bindings/python/tests/test_gettext.py | 1 - 1 file changed, 1 deletion(-) diff --git a/bindings/python/tests/test_gettext.py b/bindings/python/tests/test_gettext.py index fd56fa5a37..6a5af0fd5a 100644 --- a/bindings/python/tests/test_gettext.py +++ b/bindings/python/tests/test_gettext.py @@ -4,7 +4,6 @@ # @author Christoph Holtermann from unittest import TestCase, main -# import gettext import gnucash from gnucash import _sw_core_utils From 7bf38ef837701fb0be45e8c52ea8a36f6dfba0af Mon Sep 17 00:00:00 2001 From: c-holtermann Date: Thu, 28 May 2020 20:29:33 +0200 Subject: [PATCH 12/16] test info --- bindings/python/tests/test_gettext.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/bindings/python/tests/test_gettext.py b/bindings/python/tests/test_gettext.py index 6a5af0fd5a..9138cc59b0 100644 --- a/bindings/python/tests/test_gettext.py +++ b/bindings/python/tests/test_gettext.py @@ -17,11 +17,18 @@ class TestGettext(TestCase): def test_get_localedir(self): _localedir = _sw_core_utils.gnc_path_get_localedir() - #def test_translation(self): - # import inspect - # import locale - # raise MyException({'_(""): ':_(""), '_sw_core_utils.gnc_path_get_localedir(): ':_sw_core_utils.gnc_path_get_localedir(),'_.__doc__': _.__doc__, 'inspect.getsource(_): ': inspect.getsource(_), '_("Welcome to GnuCash")':_("Welcome to GnuCash"), 'locale.getlocale(): ': locale.getlocale()}) - # self.assertTrue("Project-Id-Version: GnuCash" in _("")) + def test_translation(self): + import inspect + import locale + import gettext + _localedir = _sw_core_utils.gnc_path_get_localedir() + + t = gettext.translation(_sw_core_utils.GETTEXT_PACKAGE, _localedir) + + self.assertIn("project-id-version", t.info()) + self.assertIn("GnuCash", t.info()["project-id-version"]) + raise MyException({'_(""): ':_(""), '_sw_core_utils.gnc_path_get_localedir(): ':_sw_core_utils.gnc_path_get_localedir(),'_.__doc__': _.__doc__, 'inspect.getsource(_): ': inspect.getsource(_), '_("Welcome to GnuCash")':_("Welcome to GnuCash"), 'locale.getlocale(): ': locale.getlocale(), 't:': t, 't.gettext(""): ': t.gettext(""), 't.info(): ': t.info()}) + self.assertTrue("Project-Id-Version: GnuCash" in _("")) if __name__ == '__main__': main() From 9e678a421e81ca42f4e29e9d6114396321a9beac Mon Sep 17 00:00:00 2001 From: c-holtermann Date: Thu, 28 May 2020 20:31:16 +0200 Subject: [PATCH 13/16] remove debug stuff --- bindings/python/tests/test_gettext.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/bindings/python/tests/test_gettext.py b/bindings/python/tests/test_gettext.py index 9138cc59b0..af5b63074e 100644 --- a/bindings/python/tests/test_gettext.py +++ b/bindings/python/tests/test_gettext.py @@ -7,8 +7,6 @@ from unittest import TestCase, main import gnucash from gnucash import _sw_core_utils -class MyException(Exception): - pass class TestGettext(TestCase): def test_import_gettext(self): @@ -18,17 +16,11 @@ class TestGettext(TestCase): _localedir = _sw_core_utils.gnc_path_get_localedir() def test_translation(self): - import inspect - import locale import gettext _localedir = _sw_core_utils.gnc_path_get_localedir() - t = gettext.translation(_sw_core_utils.GETTEXT_PACKAGE, _localedir) - self.assertIn("project-id-version", t.info()) self.assertIn("GnuCash", t.info()["project-id-version"]) - raise MyException({'_(""): ':_(""), '_sw_core_utils.gnc_path_get_localedir(): ':_sw_core_utils.gnc_path_get_localedir(),'_.__doc__': _.__doc__, 'inspect.getsource(_): ': inspect.getsource(_), '_("Welcome to GnuCash")':_("Welcome to GnuCash"), 'locale.getlocale(): ': locale.getlocale(), 't:': t, 't.gettext(""): ': t.gettext(""), 't.info(): ': t.info()}) - self.assertTrue("Project-Id-Version: GnuCash" in _("")) if __name__ == '__main__': main() From e1701fbdd6c0f2ecde768eca1c70613b02ff1289 Mon Sep 17 00:00:00 2001 From: c-holtermann Date: Thu, 28 May 2020 20:42:27 +0200 Subject: [PATCH 14/16] locale is not needed anymore (debug) --- bindings/python/gnucash_core.py | 1 - 1 file changed, 1 deletion(-) diff --git a/bindings/python/gnucash_core.py b/bindings/python/gnucash_core.py index ffa4864b95..b82c5a53b9 100644 --- a/bindings/python/gnucash_core.py +++ b/bindings/python/gnucash_core.py @@ -49,7 +49,6 @@ from gnucash.gnucash_core_c import gncInvoiceLookup, gncInvoiceGetInvoiceFromTxn try: import gettext - import locale _localedir = _sw_core_utils.gnc_path_get_localedir() gettext.install(_sw_core_utils.GETTEXT_PACKAGE, _localedir) From b13f40aeafac4b07abc7d82973639ed2198a99fc Mon Sep 17 00:00:00 2001 From: c-holtermann Date: Thu, 28 May 2020 20:55:15 +0200 Subject: [PATCH 15/16] remove translation test --- bindings/python/tests/test_gettext.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/bindings/python/tests/test_gettext.py b/bindings/python/tests/test_gettext.py index af5b63074e..c3eb891817 100644 --- a/bindings/python/tests/test_gettext.py +++ b/bindings/python/tests/test_gettext.py @@ -15,12 +15,5 @@ class TestGettext(TestCase): def test_get_localedir(self): _localedir = _sw_core_utils.gnc_path_get_localedir() - def test_translation(self): - import gettext - _localedir = _sw_core_utils.gnc_path_get_localedir() - t = gettext.translation(_sw_core_utils.GETTEXT_PACKAGE, _localedir) - self.assertIn("project-id-version", t.info()) - self.assertIn("GnuCash", t.info()["project-id-version"]) - if __name__ == '__main__': main() From 20251999a4069e969754c4bd968bbeda784c64d4 Mon Sep 17 00:00:00 2001 From: John Ralls Date: Thu, 28 May 2020 14:16:38 -0700 Subject: [PATCH 16/16] python-gettext-localize: Additional POTFILES.in changes. --- po/POTFILES.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/po/POTFILES.in b/po/POTFILES.in index 0f28d6a784..492b7dd484 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -12,6 +12,7 @@ bindings/guile/gnc-kvp-guile.cpp bindings/guile/gnc-module.scm bindings/guile/gnc-numeric.scm bindings/guile/utilities.scm +bindings/python/app_utils.py bindings/python/example_scripts/account_analysis.py bindings/python/example_scripts/change_tax_code.py bindings/python/example_scripts/gnc_convenience.py @@ -610,7 +611,6 @@ libgnucash/core-utils/gnc-path.c libgnucash/core-utils/gnc-prefs.c libgnucash/core-utils/gnc-version.c libgnucash/doc/doxygen_main_page.c -libgnucash/doc/python-bindings-doxygen.py libgnucash/engine/Account.cpp libgnucash/engine/cap-gains.c libgnucash/engine/cashobjects.c