Skip to content

Commit

Permalink
lang support
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl committed Nov 19, 2024
1 parent 912b903 commit 2fda359
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,7 @@ def _get_intent_data(self, message: Message) -> WeatherIntent:

def _get_weather_config(self, message=None):
sess = SessionManager.get(message)
cfg = {"lang": sess. lang,
cfg = {"lang": sess.lang,
"system_unit": sess.system_unit,
"location": sess.location_preferences,
"date_format": sess.date_format,
Expand Down
2 changes: 1 addition & 1 deletion weather_helpers/intent.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def geolocation(self):
if self.location is None:
self._geolocation = dict()
else:
self._geolocation = get_geolocation(self.location)
self._geolocation = get_geolocation(self.location, lang=self.config.lang)
return self._geolocation

@property
Expand Down
7 changes: 4 additions & 3 deletions weather_helpers/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import pytz
from ovos_date_parser import nice_date, extract_datetime
from ovos_utils.location import get_geolocation as _get_geo
from ovos_utils.geolocation import get_geolocation as _get_geo
from ovos_utils.time import now_local, to_local


Expand Down Expand Up @@ -82,11 +82,12 @@ def get_tz_info(timezone: str) -> tzinfo:
return pytz.timezone(timezone)


def get_geolocation(location: str):
def get_geolocation(location: str, lang: str = "en"):
"""Retrieve the geolocation information about the requested location.
Args:
location: a location specified in the utterance
lang: lang to return country/region in
Returns:
A deserialized JSON object containing geolocation information for the
Expand All @@ -95,7 +96,7 @@ def get_geolocation(location: str):
Raises:
LocationNotFound error if the API returns no results.
"""
geolocation = _get_geo(location)
geolocation = _get_geo(location, lang=lang)

if geolocation is None:
raise LocationNotFoundError(f"Location {location} is unknown")
Expand Down

0 comments on commit 2fda359

Please sign in to comment.