Skip to content

Commit

Permalink
ui/gtk2: Deprecate gettext.bind_textdomain_codeset() since Python 3.8
Browse files Browse the repository at this point in the history
setup/i18n.py is a symlink of ui/gtk2/i18n.py
env PYTHONWARNINGS='d' ibus-setup

BUG=#2276
  • Loading branch information
fujiwarat committed Nov 4, 2021
1 parent acc5570 commit 28acfd4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ui/gtk2/i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
# ibus - The Input Bus
#
# Copyright(c) 2007-2015 Peng Huang <shawn.p.huang@gmail.com>
# Copyright(c) 2012-2021 Takao Fujiwara <takao.fujiwara1@gmail.com>
# Copyright(c) 2007-2015 Google, Inc.
# Copyright(c) 2012-2021 Red Hat, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
Expand All @@ -23,12 +25,14 @@
import locale
import gettext
import os
import sys

DOMAINNAME = "ibus10"

_ = lambda a: gettext.dgettext(DOMAINNAME, a)
N_ = lambda a: a

PY3K = sys.version_info >= (3, 0)
LOCALEDIR = os.getenv("IBUS_LOCALEDIR")

def init_textdomain(domainname):
Expand All @@ -42,7 +46,9 @@ def init_textdomain(domainname):
except AttributeError:
pass
gettext.bindtextdomain(domainname, LOCALEDIR)
gettext.bind_textdomain_codeset(domainname, 'UTF-8')
# https://docs.python.org/3/library/gettext.html#gettext.lgettext
if not PY3K:
gettext.bind_textdomain_codeset(domainname, 'UTF-8')

def gettext_engine_longname(engine):
name = engine.get_name()
Expand Down

3 comments on commit 28acfd4

@gunnarhj
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @fujiwarat!

I was about to apply this in Debian, since it seems a good idea to prevent a python3.10 issue. However, we are fetching the upstream source from https://github.com/ibus/ibus/releases, and there setup/i18n.py is a regular file and not a symlink. (ui/gtk2 does not exist.)

So I got a bit confused. For now I applied this commit to setup/i18n.py directly.

https://salsa.debian.org/debian/ibus/-/commit/8f0b70f0

@fujiwarat
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gunnarhj
Thank you for the attention note. Probably I think the patch is nice to have at the moment since Python does not output the debug message in the official releases by default.

FYI. There is another symlink issue:
https://desktopi18n.wordpress.com/2021/11/12/ibus-1-5-25-is-released/

@gunnarhj
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI. There is another symlink issue

Right, thanks for mentioning it. Coincidentally we apply that patch in Debian too. 😉 But in that case I had noticed your note in the commit message.

Please sign in to comment.