From 2a416eac82c747c17d67d9c4ba08334301231900 Mon Sep 17 00:00:00 2001 From: domcross Date: Thu, 18 Mar 2021 22:16:34 +0100 Subject: [PATCH 1/5] use localized format for idle-screen/gui --- __init__.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/__init__.py b/__init__.py index efdafeef..ad061e88 100644 --- a/__init__.py +++ b/__init__.py @@ -24,6 +24,7 @@ import mycroft.audio from adapt.intent import IntentBuilder +from lingua_franca.format import date_time_format from mycroft.util.format import nice_date, nice_duration, nice_time from mycroft.messagebus.message import Message from mycroft import MycroftSkill, intent_handler @@ -622,12 +623,26 @@ def show_date_mark1(self, location, day): def get_weekday(self, day=None, location=None): if not day: day = self.get_local_datetime(location) - return day.strftime("%A") + weekday = nice_date(day) # forces lingua_franca to initialize + if self.lang in date_time_format.lang_config.keys(): + weekday = list( + date_time_format.lang_config[self.lang]['weekday'].values())[day.weekday()] + else: + weekday = day.strftime("%A") + return weekday def get_month_date(self, day=None, location=None): if not day: day = self.get_local_datetime(location) - return day.strftime("%B %d") + month = nice_date(day) # forces lingua_franca to initialize + if self.lang in date_time_format.lang_config.keys(): + month = date_time_format.lang_config[self.lang]['month'][str(int(day.strftime("%m")))] + else: + month = day.strftime("%B") + if self.config_core.get('date_format') == 'MDY': + return "{} {}".format(month, day.strftime("%d")) + else: + return "{}. {}".format(day.strftime("%d"), month) def get_year(self, day=None, location=None): if not day: From 6be59381c85e30f115c1b468ecf4b5818c7756ab Mon Sep 17 00:00:00 2001 From: domcross Date: Fri, 19 Mar 2021 08:40:43 +0100 Subject: [PATCH 2/5] rework localized dateformat in gui --- __init__.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/__init__.py b/__init__.py index ad061e88..119b88ae 100644 --- a/__init__.py +++ b/__init__.py @@ -24,8 +24,8 @@ import mycroft.audio from adapt.intent import IntentBuilder -from lingua_franca.format import date_time_format -from mycroft.util.format import nice_date, nice_duration, nice_time +from mycroft.util.format import (nice_date, nice_duration, nice_time, + date_time_format) from mycroft.messagebus.message import Message from mycroft import MycroftSkill, intent_handler from mycroft.util.parse import (extract_datetime, fuzzy_match, extract_number, @@ -623,26 +623,26 @@ def show_date_mark1(self, location, day): def get_weekday(self, day=None, location=None): if not day: day = self.get_local_datetime(location) - weekday = nice_date(day) # forces lingua_franca to initialize if self.lang in date_time_format.lang_config.keys(): - weekday = list( - date_time_format.lang_config[self.lang]['weekday'].values())[day.weekday()] + localized_day_names = list( + date_time_format.lang_config[self.lang]['weekday'].values()) + weekday = localized_day_names[day.weekday()] else: weekday = day.strftime("%A") - return weekday + return weekday.capitalize() def get_month_date(self, day=None, location=None): if not day: day = self.get_local_datetime(location) - month = nice_date(day) # forces lingua_franca to initialize if self.lang in date_time_format.lang_config.keys(): - month = date_time_format.lang_config[self.lang]['month'][str(int(day.strftime("%m")))] + localized_month_names = date_time_format.lang_config[self.lang]['month'] + month = localized_month_names[str(int(day.strftime("%m")))] else: month = day.strftime("%B") if self.config_core.get('date_format') == 'MDY': return "{} {}".format(month, day.strftime("%d")) else: - return "{}. {}".format(day.strftime("%d"), month) + return "{} {}".format(day.strftime("%d"), month) def get_year(self, day=None, location=None): if not day: From b1a228a270ad95eb1b5267491571420e3763ad68 Mon Sep 17 00:00:00 2001 From: domcross Date: Fri, 19 Mar 2021 09:46:22 +0100 Subject: [PATCH 3/5] use localized format for idle-screen/gui --- __init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/__init__.py b/__init__.py index 119b88ae..dae66d4f 100644 --- a/__init__.py +++ b/__init__.py @@ -66,6 +66,7 @@ def initialize(self): # is checked, but this requires a notifier for settings # updates from the web. now = datetime.datetime.now() + _ = nice_date(now) # forces date_time_format/lingua_franca to init callback_time = (datetime.datetime(now.year, now.month, now.day, now.hour, now.minute) + datetime.timedelta(seconds=60)) From 917d3cb7e83158fc76255e80ed3042b65b0d25b2 Mon Sep 17 00:00:00 2001 From: domcross Date: Fri, 19 Mar 2021 15:40:36 +0100 Subject: [PATCH 4/5] localized date for idle-screen/gui --- __init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/__init__.py b/__init__.py index dae66d4f..d743c36a 100644 --- a/__init__.py +++ b/__init__.py @@ -61,12 +61,13 @@ def __init__(self): self.default_timezone = None def initialize(self): + date_time_format.cache(self.lang) + # Start a callback that repeats every 10 seconds # TODO: Add mechanism to only start timer when UI setting # is checked, but this requires a notifier for settings # updates from the web. now = datetime.datetime.now() - _ = nice_date(now) # forces date_time_format/lingua_franca to init callback_time = (datetime.datetime(now.year, now.month, now.day, now.hour, now.minute) + datetime.timedelta(seconds=60)) From 0b04db34a6f089588de19179061f3c276c781f9c Mon Sep 17 00:00:00 2001 From: Kris Gesling Date: Mon, 29 Mar 2021 19:51:59 +0930 Subject: [PATCH 5/5] Ensure month is capitalized on homescreen --- __init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/__init__.py b/__init__.py index d743c36a..52f4c345 100644 --- a/__init__.py +++ b/__init__.py @@ -641,6 +641,7 @@ def get_month_date(self, day=None, location=None): month = localized_month_names[str(int(day.strftime("%m")))] else: month = day.strftime("%B") + month = month.capitalize() if self.config_core.get('date_format') == 'MDY': return "{} {}".format(month, day.strftime("%d")) else: