mirror of
https://github.com/home-assistant/core.git
synced 2025-08-04 13:15:18 +02:00
Add translations to Mealie exceptions (#133648)
This commit is contained in:
committed by
GitHub
parent
87f5a7057e
commit
ad7a334147
@@ -52,9 +52,15 @@ async def async_setup_entry(hass: HomeAssistant, entry: MealieConfigEntry) -> bo
|
|||||||
about = await client.get_about()
|
about = await client.get_about()
|
||||||
version = create_version(about.version)
|
version = create_version(about.version)
|
||||||
except MealieAuthenticationError as error:
|
except MealieAuthenticationError as error:
|
||||||
raise ConfigEntryAuthFailed from error
|
raise ConfigEntryAuthFailed(
|
||||||
|
translation_domain=DOMAIN,
|
||||||
|
translation_key="auth_failed",
|
||||||
|
) from error
|
||||||
except MealieError as error:
|
except MealieError as error:
|
||||||
raise ConfigEntryNotReady(error) from error
|
raise ConfigEntryNotReady(
|
||||||
|
translation_domain=DOMAIN,
|
||||||
|
translation_key="setup_failed",
|
||||||
|
) from error
|
||||||
|
|
||||||
if not version.valid:
|
if not version.valid:
|
||||||
LOGGER.warning(
|
LOGGER.warning(
|
||||||
|
@@ -23,7 +23,7 @@ from homeassistant.exceptions import ConfigEntryAuthFailed
|
|||||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
|
|
||||||
from .const import LOGGER
|
from .const import DOMAIN, LOGGER
|
||||||
|
|
||||||
WEEK = timedelta(days=7)
|
WEEK = timedelta(days=7)
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ class MealieDataUpdateCoordinator[_DataT](DataUpdateCoordinator[_DataT]):
|
|||||||
super().__init__(
|
super().__init__(
|
||||||
hass,
|
hass,
|
||||||
LOGGER,
|
LOGGER,
|
||||||
name=self._name,
|
name=f"Mealie {self._name}",
|
||||||
update_interval=self._update_interval,
|
update_interval=self._update_interval,
|
||||||
)
|
)
|
||||||
self.client = client
|
self.client = client
|
||||||
@@ -63,9 +63,15 @@ class MealieDataUpdateCoordinator[_DataT](DataUpdateCoordinator[_DataT]):
|
|||||||
try:
|
try:
|
||||||
return await self._async_update_internal()
|
return await self._async_update_internal()
|
||||||
except MealieAuthenticationError as error:
|
except MealieAuthenticationError as error:
|
||||||
raise ConfigEntryAuthFailed from error
|
raise ConfigEntryAuthFailed(
|
||||||
|
translation_domain=DOMAIN,
|
||||||
|
translation_key="auth_failed",
|
||||||
|
) from error
|
||||||
except MealieConnectionError as error:
|
except MealieConnectionError as error:
|
||||||
raise UpdateFailed(error) from error
|
raise UpdateFailed(
|
||||||
|
translation_domain=DOMAIN,
|
||||||
|
translation_key=f"update_failed_{self._name}",
|
||||||
|
) from error
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
async def _async_update_internal(self) -> _DataT:
|
async def _async_update_internal(self) -> _DataT:
|
||||||
@@ -77,7 +83,7 @@ class MealieMealplanCoordinator(
|
|||||||
):
|
):
|
||||||
"""Class to manage fetching Mealie data."""
|
"""Class to manage fetching Mealie data."""
|
||||||
|
|
||||||
_name = "MealieMealplan"
|
_name = "mealplan"
|
||||||
_update_interval = timedelta(hours=1)
|
_update_interval = timedelta(hours=1)
|
||||||
|
|
||||||
async def _async_update_internal(self) -> dict[MealplanEntryType, list[Mealplan]]:
|
async def _async_update_internal(self) -> dict[MealplanEntryType, list[Mealplan]]:
|
||||||
@@ -106,7 +112,7 @@ class MealieShoppingListCoordinator(
|
|||||||
):
|
):
|
||||||
"""Class to manage fetching Mealie Shopping list data."""
|
"""Class to manage fetching Mealie Shopping list data."""
|
||||||
|
|
||||||
_name = "MealieShoppingList"
|
_name = "shopping_list"
|
||||||
_update_interval = timedelta(minutes=5)
|
_update_interval = timedelta(minutes=5)
|
||||||
|
|
||||||
async def _async_update_internal(
|
async def _async_update_internal(
|
||||||
@@ -130,7 +136,7 @@ class MealieShoppingListCoordinator(
|
|||||||
class MealieStatisticsCoordinator(MealieDataUpdateCoordinator[Statistics]):
|
class MealieStatisticsCoordinator(MealieDataUpdateCoordinator[Statistics]):
|
||||||
"""Class to manage fetching Mealie Statistics data."""
|
"""Class to manage fetching Mealie Statistics data."""
|
||||||
|
|
||||||
_name = "MealieStatistics"
|
_name = "statistics"
|
||||||
_update_interval = timedelta(minutes=15)
|
_update_interval = timedelta(minutes=15)
|
||||||
|
|
||||||
async def _async_update_internal(
|
async def _async_update_internal(
|
||||||
|
@@ -61,7 +61,7 @@ rules:
|
|||||||
comment: |
|
comment: |
|
||||||
This integration does not have any irrelevant entities.
|
This integration does not have any irrelevant entities.
|
||||||
entity-translations: done
|
entity-translations: done
|
||||||
exception-translations: todo
|
exception-translations: done
|
||||||
icon-translations: done
|
icon-translations: done
|
||||||
reconfiguration-flow: done
|
reconfiguration-flow: done
|
||||||
repair-issues:
|
repair-issues:
|
||||||
|
@@ -126,6 +126,21 @@
|
|||||||
},
|
},
|
||||||
"version_error": {
|
"version_error": {
|
||||||
"message": "You are running {mealie_version} of Mealie. Minimum required version is {min_version}. Please upgrade Mealie and then retry."
|
"message": "You are running {mealie_version} of Mealie. Minimum required version is {min_version}. Please upgrade Mealie and then retry."
|
||||||
|
},
|
||||||
|
"auth_failed": {
|
||||||
|
"message": "Authentication failed. Please reauthenticate."
|
||||||
|
},
|
||||||
|
"update_failed_mealplan": {
|
||||||
|
"message": "Could not fetch mealplan data."
|
||||||
|
},
|
||||||
|
"update_failed_shopping_list": {
|
||||||
|
"message": "Could not fetch shopping list data."
|
||||||
|
},
|
||||||
|
"update_failed_statistics": {
|
||||||
|
"message": "Could not fetch statistics data."
|
||||||
|
},
|
||||||
|
"setup_failed": {
|
||||||
|
"message": "Could not connect to the Mealie instance."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"services": {
|
"services": {
|
||||||
|
Reference in New Issue
Block a user