Skip to content

Commit 229b29d

Browse files
authored
Merge pull request slgobinath#706 from deltragon/typing-gettext
typing: import gettext instead of global function
2 parents c444e44 + 91f47ef commit 229b29d

File tree

18 files changed

+70
-24
lines changed

18 files changed

+70
-24
lines changed

ruff.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
target-version = "py310"
22

3-
# gettext
4-
builtins = ["_"]
5-
63
[lint]
74
select = ["E", "W", "F", "D2", "D3", "D4"]
85
ignore = [

safeeyes/__main__.py

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,18 @@
2121
"""
2222

2323
import argparse
24-
import gettext
25-
import locale
2624
import logging
2725
import signal
2826
import sys
2927

3028
import psutil
31-
from safeeyes import utility
29+
from safeeyes import utility, translations
30+
from safeeyes.translations import translate as _
3231
from safeeyes.model import Config
3332
from safeeyes.safeeyes import SafeEyes
3433
from safeeyes.safeeyes import SAFE_EYES_VERSION
3534
from safeeyes.rpc import RPCClient
3635

37-
gettext.install("safeeyes", utility.LOCALE_PATH)
38-
3936

4037
def __running():
4138
"""Check if SafeEyes is already running."""
@@ -68,21 +65,7 @@ def __running():
6865

6966
def main():
7067
"""Start the Safe Eyes."""
71-
system_locale = gettext.translation(
72-
"safeeyes",
73-
localedir=utility.LOCALE_PATH,
74-
languages=[utility.system_locale(), "en_US"],
75-
fallback=True,
76-
)
77-
system_locale.install()
78-
try:
79-
# locale.bindtextdomain is required for Glade files
80-
locale.bindtextdomain("safeeyes", utility.LOCALE_PATH)
81-
except AttributeError:
82-
logging.warning(
83-
"installed python's gettext module does not support locale.bindtextdomain."
84-
" locale.bindtextdomain is required for Glade files"
85-
)
68+
system_locale = translations.setup()
8669

8770
parser = argparse.ArgumentParser(prog="safeeyes")
8871
group = parser.add_mutually_exclusive_group()

safeeyes/model.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
from gi.repository import Gtk
3535

3636
from safeeyes import utility
37+
from safeeyes.translations import translate as _
3738

3839

3940
class Break:

safeeyes/plugins/donotdisturb/dependency_checker.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818

1919
from safeeyes import utility
20+
from safeeyes.translations import translate as _
2021

2122

2223
def validate(plugin_config, plugin_settings):

safeeyes/plugins/healthstats/dependency_checker.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818

1919
from safeeyes import utility
20+
from safeeyes.translations import translate as _
2021

2122

2223
def validate(plugin_config, plugin_settings):

safeeyes/plugins/healthstats/plugin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import croniter
2222
import datetime
2323
import logging
24+
from safeeyes.translations import translate as _
2425

2526
context = None
2627
session = None

safeeyes/plugins/limitconsecutiveskipping/plugin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"""Limit how many breaks can be skipped or postponed in a row."""
2020

2121
import logging
22+
from safeeyes.translations import translate as _
2223

2324
context = None
2425
no_of_skipped_breaks = 0

safeeyes/plugins/notification/plugin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import gi
2222
from safeeyes.model import BreakType
23+
from safeeyes.translations import translate as _
2324

2425
gi.require_version("Notify", "0.7")
2526
from gi.repository import Notify

safeeyes/plugins/smartpause/dependency_checker.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818

1919
from safeeyes import utility
20+
from safeeyes.translations import translate as _
2021

2122

2223
def validate(plugin_config, plugin_settings):

safeeyes/plugins/trayicon/dependency_checker.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
from safeeyes import utility
2020
from safeeyes.model import PluginDependency
21+
from safeeyes.translations import translate as _
2122

2223
import gi
2324

0 commit comments

Comments
 (0)