Spaces:
Runtime error
Runtime error
Update components/CodriaoCore.py
Browse files
components/CodriaoCore.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import aiohttp
|
| 2 |
import json
|
| 3 |
import logging
|
|
@@ -119,8 +120,11 @@ class CodriaoCore:
|
|
| 119 |
|
| 120 |
# Multi-language support
|
| 121 |
if language != "en":
|
| 122 |
-
|
| 123 |
-
|
|
|
|
|
|
|
|
|
|
| 124 |
|
| 125 |
return result
|
| 126 |
|
|
@@ -152,3 +156,6 @@ class CodriaoCore:
|
|
| 152 |
return decode(token, self.jwt_secret, algorithms=["HS256"])
|
| 153 |
except ExpiredSignatureError:
|
| 154 |
return None
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
import aiohttp
|
| 3 |
import json
|
| 4 |
import logging
|
|
|
|
| 120 |
|
| 121 |
# Multi-language support
|
| 122 |
if language != "en":
|
| 123 |
+
try:
|
| 124 |
+
translated_result = GoogleTranslator(source="auto", target=language).translate(json.dumps(result))
|
| 125 |
+
return json.loads(translated_result)
|
| 126 |
+
except Exception as e:
|
| 127 |
+
result["translation_error"] = str(e)
|
| 128 |
|
| 129 |
return result
|
| 130 |
|
|
|
|
| 156 |
return decode(token, self.jwt_secret, algorithms=["HS256"])
|
| 157 |
except ExpiredSignatureError:
|
| 158 |
return None
|
| 159 |
+
|
| 160 |
+
async def shutdown(self):
|
| 161 |
+
await self.http_session.close()
|