aboutsummaryrefslogtreecommitdiffstats
path: root/community/portfolio/0002-fall-back-to-gettext-module-on-systems-that.patch
diff options
context:
space:
mode:
Diffstat (limited to 'community/portfolio/0002-fall-back-to-gettext-module-on-systems-that.patch')
-rw-r--r--community/portfolio/0002-fall-back-to-gettext-module-on-systems-that.patch219
1 files changed, 0 insertions, 219 deletions
diff --git a/community/portfolio/0002-fall-back-to-gettext-module-on-systems-that.patch b/community/portfolio/0002-fall-back-to-gettext-module-on-systems-that.patch
deleted file mode 100644
index 4fec99783dc..00000000000
--- a/community/portfolio/0002-fall-back-to-gettext-module-on-systems-that.patch
+++ /dev/null
@@ -1,219 +0,0 @@
-From aad5dc56192584301bcdbd8e67d7f1157959ad06 Mon Sep 17 00:00:00 2001
-From: Clayton Craft <clayton@craftyguy.net>
-Date: Wed, 3 Mar 2021 14:45:18 -0800
-Subject: [PATCH 1/2] translation: encapsulate gettext to handle systems
- without glibc
-
-Some systems include python without glibc support, and will fail to find
-gettext, bindtextdomain, etc in the locale module. One such system/OS
-without glibc is Alpine Linux / postmarketOS.
-
-This change moves gettext loading to a new wrapper that will fall back
-to using the python gettext implementation [1] if python is built
-without glibc support.
-
-1. https://github.com/hannosch/python-gettext
----
- src/dev.tchx84.Portfolio.in | 6 +++---
- src/meson.build | 1 +
- src/places.py | 3 +--
- src/translation.py | 21 +++++++++++++++++++++
- src/window.py | 3 ++-
- src/worker.py | 2 +-
- 6 files changed, 29 insertions(+), 7 deletions(-)
- create mode 100644 src/translation.py
-
-diff --git a/src/dev.tchx84.Portfolio.in b/src/dev.tchx84.Portfolio.in
-index 9a9068a..b47d863 100755
---- a/src/dev.tchx84.Portfolio.in
-+++ b/src/dev.tchx84.Portfolio.in
-@@ -29,13 +29,13 @@ localedir = '@localedir@'
- sys.path.insert(1, pkgdatadir)
- signal.signal(signal.SIGINT, signal.SIG_DFL)
-
--locale.bindtextdomain('portfolio', localedir)
--locale.textdomain('portfolio')
--
- if __name__ == '__main__':
- from gi.repository import Gio
- resource = Gio.Resource.load(os.path.join(pkgdatadir, 'portfolio.gresource'))
- resource._register()
-
-+ from portfolio.translation import translation_init
-+ translation_init(localedir)
-+
- from portfolio import main
- sys.exit(main.main(VERSION))
-diff --git a/src/meson.build b/src/meson.build
-index 801a8ee..a9d9d77 100644
---- a/src/meson.build
-+++ b/src/meson.build
-@@ -37,6 +37,7 @@ portfolio_sources = [
- 'utils.py',
- 'service.py',
- 'place.py',
-+ 'translation.py',
- ]
-
- install_data(portfolio_sources, install_dir: moduledir)
-diff --git a/src/places.py b/src/places.py
-index 1cbbbe6..2bed48c 100644
---- a/src/places.py
-+++ b/src/places.py
-@@ -17,12 +17,11 @@
-
- import os
-
--from locale import gettext as _
--
- from gi.repository import GLib, Gio, Gtk, GObject, Handy
-
- from . import logger
- from .place import PortfolioPlace
-+from .translation import gettext as _
-
-
- class PortfolioPlaces(Gtk.Stack):
-diff --git a/src/translation.py b/src/translation.py
-new file mode 100644
-index 0000000..51f648b
---- /dev/null
-+++ b/src/translation.py
-@@ -0,0 +1,21 @@
-+import locale
-+
-+try:
-+ from locale import gettext as _
-+except ImportError:
-+ from gettext import gettext as _
-+
-+
-+def translation_init(localedir):
-+ try:
-+ locale.bindtextdomain("portfolio", localedir)
-+ locale.textdomain("portfolio")
-+ except AttributeError:
-+ import gettext
-+
-+ gettext.bindtextdomain("portfolio", localedir)
-+ gettext.textdomain("portfolio")
-+
-+
-+def gettext(*args, **kwargs):
-+ return _(*args, **kwargs)
-diff --git a/src/window.py b/src/window.py
-index 5f3ec80..df7ddb7 100644
---- a/src/window.py
-+++ b/src/window.py
-@@ -18,7 +18,8 @@
- import os
-
- from pathlib import Path
--from locale import gettext as _
-+
-+from .translation import gettext as _
-
- from gi.repository import Gtk, GLib, Gio, Handy, GObject
-
-diff --git a/src/worker.py b/src/worker.py
-index 253ec96..3c8e649 100644
---- a/src/worker.py
-+++ b/src/worker.py
-@@ -21,11 +21,11 @@
- import datetime
- import threading
-
--from locale import gettext as _
- from gi.repository import Gio, GObject, GLib
-
- from . import utils
- from . import logger
-+from .translation import gettext as _
-
-
- class WorkerStoppedException(Exception):
-
-From e66cd9125fcccfcf700189684964019e631fe585 Mon Sep 17 00:00:00 2001
-From: Martin Abente Lahaye <martin.abente.lahaye@gmail.com>
-Date: Fri, 5 Mar 2021 07:23:28 -0300
-Subject: [PATCH 2/2] translation: Refactor into a single init function
-
-This will make it easier to trace the different
-scenarios, e.g. with logging, etc.
----
- src/dev.tchx84.Portfolio.in | 4 ++--
- src/translation.py | 44 ++++++++++++++++++++++++++-----------
- 2 files changed, 33 insertions(+), 15 deletions(-)
-
-diff --git a/src/dev.tchx84.Portfolio.in b/src/dev.tchx84.Portfolio.in
-index b47d863..6719bca 100755
---- a/src/dev.tchx84.Portfolio.in
-+++ b/src/dev.tchx84.Portfolio.in
-@@ -34,8 +34,8 @@ if __name__ == '__main__':
- resource = Gio.Resource.load(os.path.join(pkgdatadir, 'portfolio.gresource'))
- resource._register()
-
-- from portfolio.translation import translation_init
-- translation_init(localedir)
-+ from portfolio import translation
-+ translation.init(localedir)
-
- from portfolio import main
- sys.exit(main.main(VERSION))
-diff --git a/src/translation.py b/src/translation.py
-index 51f648b..10df47c 100644
---- a/src/translation.py
-+++ b/src/translation.py
-@@ -1,21 +1,39 @@
--import locale
-+# translation.py
-+#
-+# Copyright 2021 Clayton Craft
-+# Copyright 2021 Martin Abente Lahaye
-+#
-+# This program is free software: you can redistribute it and/or modify
-+# it under the terms of the GNU General Public License as published by
-+# the Free Software Foundation, either version 3 of the License, or
-+# (at your option) any later version.
-+#
-+# This program is distributed in the hope that it will be useful,
-+# but WITHOUT ANY WARRANTY; without even the implied warranty of
-+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+# GNU General Public License for more details.
-+#
-+# You should have received a copy of the GNU General Public License
-+# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
--try:
-- from locale import gettext as _
--except ImportError:
-- from gettext import gettext as _
-+from . import logger
-
-+gettext = lambda msg: msg
-+
-+
-+def init(localedir):
-+ global gettext
-
--def translation_init(localedir):
- try:
-+ import locale
-+
-+ gettext = locale.gettext
- locale.bindtextdomain("portfolio", localedir)
- locale.textdomain("portfolio")
- except AttributeError:
-- import gettext
--
-- gettext.bindtextdomain("portfolio", localedir)
-- gettext.textdomain("portfolio")
--
-+ logger.debug("Using fallback gettext module")
-+ import gettext as _gettext
-
--def gettext(*args, **kwargs):
-- return _(*args, **kwargs)
-+ gettext = _gettext.gettext
-+ _gettext.bindtextdomain("portfolio", localedir)
-+ _gettext.textdomain("portfolio")