locale to direct translation

This commit is contained in:
Gaël Honorez
2023-12-31 19:23:32 +01:00
parent 6711db86f3
commit 8ff4c61afa

View File

@@ -62,12 +62,19 @@ class SubStackTask:
def get_fr_date(self): def get_fr_date(self):
locale.setlocale(locale.LC_TIME, 'fr_FR') # Mapping of English month names to French
months_en_to_fr = {
'January': 'Janvier', 'February': 'Février', 'March': 'Mars',
'April': 'Avril', 'May': 'Mai', 'June': 'Juin',
'July': 'Juillet', 'August': 'Août', 'September': 'Septembre',
'October': 'Octobre', 'November': 'Novembre', 'December': 'Décembre'
}
today = datetime.datetime.now() today = datetime.datetime.now()
today = today.strftime("%d %B %Y") formatted_date = today.strftime("%d %B %Y")
locale.setlocale(locale.LC_TIME, 'C') # Replace the English month with the French month
return today for en, fr in months_en_to_fr.items():
formatted_date = formatted_date.replace(en, fr)
return formatted_date
async def run_daily_at_6_am(self): async def run_daily_at_6_am(self):
while True: while True: