Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Localized weekday names in forecast gui #156

Open
wants to merge 4 commits into
base: 20.08
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from mycroft.messagebus.message import Message
from mycroft.util.log import LOG
from mycroft.util.format import (nice_date, nice_time, nice_number,
pronounce_number, join_list)
pronounce_number, join_list, date_time_format)
from mycroft.util.parse import extract_datetime, extract_number
from mycroft.util.time import now_local, to_utc, to_local

Expand Down Expand Up @@ -308,7 +308,9 @@ def initialize(self):
except Exception as e:
self.log.warning('Could not prepare forecasts. '
'({})'.format(repr(e)))


date_time_format.cache(self.lang)

# self.test_screen() # DEBUG: Used during screen testing/debugging

def test_screen(self):
Expand Down Expand Up @@ -369,14 +371,17 @@ def get_coming_days_forecast(self, forecast, unit, days=None):
Returns: List of dicts containg weather info
"""
days = days or 4
weekdays = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
if self.lang in date_time_format.lang_config.keys():
weekdays = list(date_time_format.lang_config[self.lang]['weekday'].values())
else:
weekdays = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
forecast_list = []
# Get tomorrow and 4 days forward
for weather in list(forecast.get_weathers())[1:5]:
result_temp = weather.get_temperature(unit)
day_num = datetime.weekday(
datetime.fromtimestamp(weather.get_reference_time()))
result_temp_day = weekdays[day_num]
result_temp_day = weekdays[day_num][:3]
forecast_list.append({
"weathercode": self.CODES[weather.get_weather_icon_name()],
"max": round(result_temp['max']),
Expand Down