From 301465a49ad62a296d9444b141f6366e65489618 Mon Sep 17 00:00:00 2001 From: Delirious Lettuce Date: Mon, 10 Jul 2017 20:11:04 -0600 Subject: [PATCH] Reorder imports, remove `p`, use `ext`, use `json.load(f)` --- onionshare/strings.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/onionshare/strings.py b/onionshare/strings.py index 9b26b4b1..7a1f08a5 100644 --- a/onionshare/strings.py +++ b/onionshare/strings.py @@ -17,17 +17,19 @@ 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 . """ -import json, locale, os +import json +import locale +import os strings = {} + def load_strings(common, default="en"): """ Loads translated strings and fallback to English if the translation does not exist. """ global strings - p = common.get_platform() # find locale dir locale_dir = common.get_resource_path('locale') @@ -37,10 +39,9 @@ def load_strings(common, default="en"): for filename in os.listdir(locale_dir): abs_filename = os.path.join(locale_dir, filename) lang, ext = os.path.splitext(filename) - if abs_filename.endswith('.json'): + if ext == '.json': with open(abs_filename, encoding='utf-8') as f: - lang_json = f.read() - translations[lang] = json.loads(lang_json) + translations[lang] = json.load(f) strings = translations[default] lc, enc = locale.getdefaultlocale()