[gedit-plugins] Translate plugin: cache _fetch_remote_language_names values per session since names of languages wil



commit 852d16e8fa9fbe804375fdae8f95d02aefbf5125
Author: Jordi Mas <jmas softcatala org>
Date:   Fri May 3 22:21:11 2019 +0200

    Translate plugin: cache _fetch_remote_language_names values per session since names of languages will 
unlike to change. Prevents a http request everytime that we use the contextual menu with Yandex engine

 plugins/translate/translate/services/yandex.py | 5 +++++
 1 file changed, 5 insertions(+)
---
diff --git a/plugins/translate/translate/services/yandex.py b/plugins/translate/translate/services/yandex.py
index ae4ee1c..c50065d 100644
--- a/plugins/translate/translate/services/yandex.py
+++ b/plugins/translate/translate/services/yandex.py
@@ -103,6 +103,11 @@ class Yandex(Service):
             if len(self._key) == 0:
                 return
 
+            if (len(Yandex.g_locales_names) > 0 and
+               len(Yandex.g_language_names) > 0 and
+               len(Yandex.g_language_codes) > 0):
+                    return
+
             url = "{0}/getLangs?ui=en&key={1}".format(self.SERVER, self._key)
             response = urllib.request.urlopen(url)
             payload = json.loads(response.read().decode("utf-8"))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]