From 8ff4c61afa0a656a1b8107a81917225c14762b6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20Honorez?= Date: Sun, 31 Dec 2023 19:23:32 +0100 Subject: [PATCH] locale to direct translation --- Post_RSS_on_SubStack.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/Post_RSS_on_SubStack.py b/Post_RSS_on_SubStack.py index b316ea3..9dd8156 100644 --- a/Post_RSS_on_SubStack.py +++ b/Post_RSS_on_SubStack.py @@ -62,12 +62,19 @@ class SubStackTask: 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 = today.strftime("%d %B %Y") - locale.setlocale(locale.LC_TIME, 'C') - return today - + formatted_date = today.strftime("%d %B %Y") + # Replace the English month with the French month + 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): while True: