gnucash master: Multiple changes pushed
John Ralls
jralls at code.gnucash.org
Thu May 28 17:17:58 EDT 2020
Updated via https://github.com/Gnucash/gnucash/commit/5091d7a6 (commit)
via https://github.com/Gnucash/gnucash/commit/20251999 (commit)
via https://github.com/Gnucash/gnucash/commit/b13f40ae (commit)
via https://github.com/Gnucash/gnucash/commit/e1701fbd (commit)
via https://github.com/Gnucash/gnucash/commit/9e678a42 (commit)
via https://github.com/Gnucash/gnucash/commit/7bf38ef8 (commit)
via https://github.com/Gnucash/gnucash/commit/ca21f322 (commit)
via https://github.com/Gnucash/gnucash/commit/efe9b4b6 (commit)
via https://github.com/Gnucash/gnucash/commit/f788e593 (commit)
via https://github.com/Gnucash/gnucash/commit/fc87e275 (commit)
via https://github.com/Gnucash/gnucash/commit/8d429d82 (commit)
via https://github.com/Gnucash/gnucash/commit/2c09fe4f (commit)
via https://github.com/Gnucash/gnucash/commit/694e5a26 (commit)
via https://github.com/Gnucash/gnucash/commit/31d2b3cb (commit)
via https://github.com/Gnucash/gnucash/commit/101a2ca0 (commit)
via https://github.com/Gnucash/gnucash/commit/22848c6b (commit)
via https://github.com/Gnucash/gnucash/commit/41dc6ddb (commit)
from https://github.com/Gnucash/gnucash/commit/890637b2 (commit)
commit 5091d7a670e35feb1ff60684300785ffef79c691
Merge: 890637b2d 20251999a
Author: John Ralls <jralls at ceridwen.us>
Date: Thu May 28 14:17:10 2020 -0700
Merge Christoph Holterman's python-gettext-localize into master.
commit 20251999a4069e969754c4bd968bbeda784c64d4
Author: John Ralls <jralls at ceridwen.us>
Date: Thu May 28 14:16:38 2020 -0700
python-gettext-localize: Additional POTFILES.in changes.
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 0f28d6a78..492b7dd48 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
commit b13f40aeafac4b07abc7d82973639ed2198a99fc
Author: c-holtermann <mail at c-holtermann.net>
Date: Thu May 28 20:55:15 2020 +0200
remove translation test
diff --git a/bindings/python/tests/test_gettext.py b/bindings/python/tests/test_gettext.py
index af5b63074..c3eb89181 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()
commit e1701fbdd6c0f2ecde768eca1c70613b02ff1289
Author: c-holtermann <mail at c-holtermann.net>
Date: Thu May 28 20:42:27 2020 +0200
locale is not needed anymore (debug)
diff --git a/bindings/python/gnucash_core.py b/bindings/python/gnucash_core.py
index ffa4864b9..b82c5a53b 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)
commit 9e678a421e81ca42f4e29e9d6114396321a9beac
Author: c-holtermann <mail at c-holtermann.net>
Date: Thu May 28 20:31:16 2020 +0200
remove debug stuff
diff --git a/bindings/python/tests/test_gettext.py b/bindings/python/tests/test_gettext.py
index 9138cc59b..af5b63074 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()
commit 7bf38ef837701fb0be45e8c52ea8a36f6dfba0af
Author: c-holtermann <mail at c-holtermann.net>
Date: Thu May 28 20:29:33 2020 +0200
test info
diff --git a/bindings/python/tests/test_gettext.py b/bindings/python/tests/test_gettext.py
index 6a5af0fd5..9138cc59b 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()
commit ca21f3224935c2b73b23a977c84dc0c8c208b2a3
Author: c-holtermann <mail at c-holtermann.net>
Date: Thu May 28 20:21:31 2020 +0200
remove global gettext import
diff --git a/bindings/python/tests/test_gettext.py b/bindings/python/tests/test_gettext.py
index fd56fa5a3..6a5af0fd5 100644
--- a/bindings/python/tests/test_gettext.py
+++ b/bindings/python/tests/test_gettext.py
@@ -4,7 +4,6 @@
# @author Christoph Holtermann <mail at c-holtermann.net>
from unittest import TestCase, main
-# import gettext
import gnucash
from gnucash import _sw_core_utils
commit efe9b4b606f72e92082507e47eb47e98b8e4381c
Author: c-holtermann <mail at c-holtermann.net>
Date: Thu May 28 20:19:39 2020 +0200
remove debug info
diff --git a/bindings/python/gnucash_core.py b/bindings/python/gnucash_core.py
index bc118d425..ffa4864b9 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"""
commit f788e593185ef3bcf460c330ac81bfe200bd8aba
Author: c-holtermann <mail at c-holtermann.net>
Date: Tue Apr 28 20:57:58 2020 +0200
remove debug stuff (temporarily)
diff --git a/bindings/python/tests/test_gettext.py b/bindings/python/tests/test_gettext.py
index 7a81d5e64..fd56fa5a3 100644
--- a/bindings/python/tests/test_gettext.py
+++ b/bindings/python/tests/test_gettext.py
@@ -4,7 +4,7 @@
# @author Christoph Holtermann <mail at c-holtermann.net>
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()
commit fc87e275faab37f3af3329c5d3e119426fd3c689
Author: c-holtermann <mail at c-holtermann.net>
Date: Tue Apr 28 19:09:42 2020 +0200
further debugging
diff --git a/bindings/python/tests/test_gettext.py b/bindings/python/tests/test_gettext.py
index e69a6f8b9..7a81d5e64 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__':
commit 8d429d82956ee056f381d8af964b820a33205d5e
Author: c-holtermann <mail at c-holtermann.net>
Date: Tue Apr 28 18:41:43 2020 +0200
further debugging
diff --git a/bindings/python/tests/test_gettext.py b/bindings/python/tests/test_gettext.py
index 9565c631b..e69a6f8b9 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__':
commit 2c09fe4f44fa928112439f0123779df1546a25a9
Author: c-holtermann <mail at c-holtermann.net>
Date: Mon Apr 27 22:08:15 2020 +0200
debug on travis
diff --git a/bindings/python/tests/test_gettext.py b/bindings/python/tests/test_gettext.py
index 1e53a86ed..9565c631b 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__':
commit 694e5a26ff312f841ad9eceb9f75b20099d6966a
Author: c-holtermann <mail at c-holtermann.net>
Date: Wed Apr 8 07:33:15 2020 +0200
add test for gettext
diff --git a/bindings/python/tests/CMakeLists.txt b/bindings/python/tests/CMakeLists.txt
index dca317de4..e118e5a6c 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 4e6ccc4e3..8f88d8eb6 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 000000000..1e53a86ed
--- /dev/null
+++ b/bindings/python/tests/test_gettext.py
@@ -0,0 +1,22 @@
+# test gettext
+#
+# @date 2020-04-08
+# @author Christoph Holtermann <mail at c-holtermann.net>
+
+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()
commit 31d2b3cb44ad92fd1575e9945da7c4debc7866f6
Author: c-holtermann <mail at c-holtermann.net>
Date: Fri Apr 10 18:16:50 2020 +0200
install gettext
diff --git a/bindings/python/gnucash_core.py b/bindings/python/gnucash_core.py
index a660c6afb..bc118d425 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 81a38b388..c042b6d26 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
commit 101a2ca09d3881eb13d97606fc49955a137d0cfc
Author: c-holtermann <mail at c-holtermann.net>
Date: Sun Mar 1 08:14:28 2020 +0100
add translatable python files
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 6041f220f..0f28d6a78 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
commit 22848c6b0aeb8c5527b2f51e762fa64c42653929
Author: c-holtermann <mail at c-holtermann.net>
Date: Sat Feb 29 15:51:07 2020 +0100
localize strings for python
diff --git a/gnucash/python/init.py b/gnucash/python/init.py
index c364b2dd4..81a38b388 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)
commit 41dc6ddbe2186eaed476e725d6cb1a0ed7207bf8
Author: c-holtermann <mail at c-holtermann.net>
Date: Sat Feb 29 16:16:05 2020 +0100
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.
diff --git a/bindings/core-utils.i b/bindings/core-utils.i
index c86977067..f66a184e8 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 6302fba46..a660c6afb 100644
--- a/bindings/python/gnucash_core.py
+++ b/bindings/python/gnucash_core.py
@@ -28,7 +28,8 @@
# @author Jeff Green, ParIT Worker Co-operative <jeff at parit.ca>
# @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 bfc319ad5..c364b2dd4 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 5c4cbaefa..51180baa0 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
)
Summary of changes:
bindings/core-utils.i | 6 ++++++
bindings/python/gnucash_core.py | 24 +++++++++++++++++++++++-
bindings/python/tests/CMakeLists.txt | 1 +
bindings/python/tests/runTests.py.in | 1 +
bindings/python/tests/test_gettext.py | 19 +++++++++++++++++++
gnucash/python/init.py | 16 +++++++++++++---
po/CMakeLists.txt | 2 +-
po/POTFILES.in | 29 +++++++++++++++++++++++++++++
8 files changed, 93 insertions(+), 5 deletions(-)
create mode 100644 bindings/python/tests/test_gettext.py
More information about the gnucash-changes
mailing list