From 6cea5304ee5d14e5632c2f98db97bba6961818c6 Mon Sep 17 00:00:00 2001
From: Alexandre Iooss <erdnaxe@crans.org>
Date: Sat, 28 Nov 2020 09:32:01 +0100
Subject: [PATCH] Fix ressourcelib context for locales

---
 cpasswords/locale.py | 3 ++-
 setup.py             | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/cpasswords/locale.py b/cpasswords/locale.py
index 5ab850e..e6536de 100644
--- a/cpasswords/locale.py
+++ b/cpasswords/locale.py
@@ -18,7 +18,8 @@ except ImportError:
 
 # Load locale
 if platform.uname().system == 'Linux':
-    gettext.bindtextdomain('messages', importlib_resources.path("cpasswords", "locale"))
+    with importlib_resources.path("cpasswords", "locale") as mo_path:
+        gettext.bindtextdomain('messages', mo_path)
     gettext.textdomain('messages')
     _ = gettext.gettext
 else:
diff --git a/setup.py b/setup.py
index 49e0a3d..8740212 100755
--- a/setup.py
+++ b/setup.py
@@ -24,7 +24,7 @@ def compile_messages():
             po.save_as_mofile(mo_file)
             mo_files.append(mo_file)
         except ImportError:
-            print("Polib is not installed, tranlation will not be compiled.")
+            print("Polib is not installed, locales will not be compiled.")
             break
     return [('locale', mo_files), ]
 
-- 
GitLab