From 988b2ae310a9e82f2372bf1a195af3dd4c6918b3 Mon Sep 17 00:00:00 2001 From: Siavash Mollayi Date: Sat, 6 Nov 2021 10:30:47 +0330 Subject: [PATCH] reset to prev locale after parsing --- lingua_franca/lang/parse_az.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lingua_franca/lang/parse_az.py b/lingua_franca/lang/parse_az.py index cd2b143d..0046f5ea 100644 --- a/lingua_franca/lang/parse_az.py +++ b/lingua_franca/lang/parse_az.py @@ -17,7 +17,7 @@ from typing import List from datetime import datetime, timedelta import locale -locale.setlocale(locale.LC_TIME, "az_AZ") + from dateutil.relativedelta import relativedelta from lingua_franca.time import now_local @@ -32,7 +32,7 @@ import re import json -from lingua_franca.internal import resolve_resource_file +from lingua_franca.internal import get_default_lang, resolve_resource_file def _remove_ak(): pass @@ -1104,7 +1104,9 @@ def date_found(): # perform date manipulation extractedDate = anchorDate.replace(microsecond=0) - + if get_default_lang() == "az": + prev_locale = locale.getlocale() + locale.setlocale(locale.LC_TIME, "az_AZ") if datestr != "": # date included an explicit date, e.g. "june 5" or "june 2, 2017" try: @@ -1172,6 +1174,9 @@ def date_found(): resultStr = " ".join(words) resultStr = ' '.join(resultStr.split()) + if get_default_lang() == "az": + prev_locale = locale.getlocale() + locale.setlocale(locale.LC_TIME, prev_locale) return [extractedDate, resultStr]