Skip to content

Commit 2b32a40

Browse files
authored
Localize user-facing provider error messages (#4259)
1 parent 8b64f5e commit 2b32a40

42 files changed

Lines changed: 240 additions & 31 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

music_assistant/providers/audiobookshelf/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,11 @@ async def handle_async_init(self) -> None:
278278
)
279279
await self._client_socket.init_client()
280280
except AbsLoginError as exc:
281-
raise LoginFailed(f"Login to abs instance at {base_url} failed.") from exc
281+
raise LoginFailed(
282+
f"Login to abs instance at {base_url} failed.",
283+
translation_key="provider.audiobookshelf.errors.login_failed",
284+
translation_args=[base_url],
285+
) from exc
282286

283287
if token_old is not None and token_api is None:
284288
# Log Message that the old token won't work

music_assistant/providers/audiobookshelf/strings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,8 @@
5252
},
5353
"manifest": {
5454
"description": "Stream audiobooks and podcasts from your personal Audiobookshelf server."
55+
},
56+
"errors": {
57+
"login_failed": "Login to the Audiobookshelf server at {0} failed."
5558
}
5659
}

music_assistant/providers/chromecast/player.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,9 @@ def launch() -> None:
402402
except TimeoutError:
403403
self.logger.warning("Timed out waiting for app launch on %s", self.display_name)
404404
raise PlayerUnavailableError(
405-
f"Timed out launching app on {self.display_name}"
405+
f"Timed out launching app on {self.display_name}",
406+
translation_key="provider.chromecast.errors.app_launch_timeout",
407+
translation_args=[self.display_name],
406408
) from None
407409

408410
### Callbacks from Chromecast Statuslistener

music_assistant/providers/chromecast/strings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,8 @@
77
},
88
"manifest": {
99
"description": "Cast music and podcasts to Chromecast or Google Cast devices."
10+
},
11+
"errors": {
12+
"app_launch_timeout": "Timed out launching app on {0}."
1013
}
1114
}

music_assistant/providers/filesystem_local/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,11 @@ async def handle_async_init(self) -> None:
230230
"""Handle async initialization of the provider."""
231231
if not await isdir(self.base_path):
232232
msg = f"Music Directory {self.base_path} does not exist"
233-
raise SetupFailedError(msg)
233+
raise SetupFailedError(
234+
msg,
235+
translation_key="provider.filesystem_local.errors.music_directory_not_found",
236+
translation_args=[self.base_path],
237+
)
234238
await self.check_write_access()
235239

236240
async def search(

music_assistant/providers/filesystem_local/strings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,8 @@
4747
},
4848
"manifest": {
4949
"description": "Play music and audiobooks stored on locally connected drives."
50+
},
51+
"errors": {
52+
"music_directory_not_found": "Music directory {0} does not exist."
5053
}
5154
}

music_assistant/providers/filesystem_nfs/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ async def setup(
4545
server = str(config.get_value(CONF_HOST))
4646
if not await get_ip_from_host(server):
4747
msg = f"Unable to resolve {server}, make sure the address is resolvable."
48-
raise SetupFailedError(msg)
48+
raise SetupFailedError(
49+
msg,
50+
translation_key="provider.filesystem_nfs.errors.host_unresolvable",
51+
translation_args=[server],
52+
)
4953
# check if export path is valid
5054
export_path = str(config.get_value(CONF_EXPORT_PATH))
5155
if not export_path or not export_path.startswith("/") or not is_safe_path(export_path):

music_assistant/providers/filesystem_nfs/strings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,8 @@
2626
},
2727
"manifest": {
2828
"description": "Play music and audiobooks stored on NFS connected network drives."
29+
},
30+
"errors": {
31+
"host_unresolvable": "Unable to resolve {0}, make sure the address is resolvable."
2932
}
3033
}

music_assistant/providers/filesystem_smb/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,12 @@ async def setup(
4848
# check if valid dns name is given for the host
4949
server = str(config.get_value(CONF_HOST))
5050
if not await get_ip_from_host(server):
51-
msg = f"Unable to resolve {server}, make sure the address is resolveable."
52-
raise LoginFailed(msg)
51+
msg = f"Unable to resolve {server}, make sure the address is resolvable."
52+
raise LoginFailed(
53+
msg,
54+
translation_key="provider.filesystem_smb.errors.unresolvable_host",
55+
translation_args=[server],
56+
)
5357
# check if share is valid
5458
share = str(config.get_value(CONF_SHARE))
5559
if not share or "/" in share or "\\" in share:

music_assistant/providers/filesystem_smb/strings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,8 @@
4444
},
4545
"manifest": {
4646
"description": "Play music and audiobooks stored on SMB connected network drives."
47+
},
48+
"errors": {
49+
"unresolvable_host": "Unable to resolve {0}, make sure the address is resolvable."
4750
}
4851
}

0 commit comments

Comments
 (0)