refactor: consolidate English translations (#6640)
This commit is contained in:
1 parent
81aa704537
commit
9e14a07e64
449 files changed
+3515
-3922
No files matched your search
@@ -8,7 +8,7 @@ import { clientApi } from "@homarr/api/client";
|
||||
import { useIntegrationsWithInteractAccess } from "@homarr/auth/client";
|
||||
import { showErrorNotification } from "@homarr/notifications";
|
||||
import { useRegisterSpotlightContextActions } from "@homarr/spotlight";
|
||||
import { useCurrentIntlLocale, useScopedI18n } from "@homarr/translation/client";
|
||||
import { useCurrentIntlLocale, useI18n } from "@homarr/translation/client";
|
||||
|
||||
import type { WidgetComponentProps } from "../../definition";
|
||||
import { isSmartHomeTiny } from "../layout";
|
||||
@@ -22,8 +22,9 @@ export default function SmartHomeEntityStateWidget({
|
||||
height,
|
||||
displayMode,
|
||||
}: WidgetComponentProps<"smartHome-entityState">) {
|
||||
const t = useScopedI18n("widget.smartHome-entityState");
|
||||
const tCommon = useScopedI18n("common");
|
||||
const t = useI18n("widget.smartHome-entityState");
|
||||
const tWidgetCommon = useI18n("widget.common");
|
||||
const tCommon = useI18n("common");
|
||||
const locale = useCurrentIntlLocale();
|
||||
// It will always have at least one integration as otherwise the NoIntegrationSelectedError would be thrown in item-content.tsx
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
@@ -163,7 +164,7 @@ export default function SmartHomeEntityStateWidget({
|
||||
})}
|
||||
</Text>
|
||||
<Text size="xs" c="dimmed">
|
||||
{t("advanced.lastUpdated", {
|
||||
{tWidgetCommon("updatedAt", {
|
||||
date: new Date(entity.last_updated).toLocaleString(locale),
|
||||
})}
|
||||
</Text>
|
||||
|
||||
@@ -60,14 +60,14 @@ export default function SmartHomeTriggerAutomationWidget({
|
||||
}
|
||||
}, [canInteract, integrationId, isEditMode, isPending, mutateAsync, options.automationId]);
|
||||
|
||||
const t = useI18n();
|
||||
const t = useI18n("widget.smartHome-executeAutomation");
|
||||
const locale = useCurrentIntlLocale();
|
||||
useRegisterSpotlightContextActions(
|
||||
`smartHome-automation-${options.automationId}`,
|
||||
[
|
||||
{
|
||||
id: options.automationId,
|
||||
name: t("widget.smartHome-executeAutomation.spotlightAction.run", { name: options.displayName }),
|
||||
name: t("spotlightAction.run", { name: options.displayName }),
|
||||
icon: IconAutomation,
|
||||
interaction() {
|
||||
return {
|
||||
@@ -89,24 +89,18 @@ export default function SmartHomeTriggerAutomationWidget({
|
||||
return (
|
||||
<Box pos="relative" w="100%" h="100%">
|
||||
<VisuallyHidden component="output">
|
||||
{isPending
|
||||
? t("widget.smartHome-executeAutomation.status.running")
|
||||
: isShowSuccess
|
||||
? t("widget.smartHome-executeAutomation.status.success")
|
||||
: ""}
|
||||
{isPending ? t("status.running") : isShowSuccess ? t("status.success") : ""}
|
||||
</VisuallyHidden>
|
||||
{error && (
|
||||
<VisuallyHidden role="alert">{t("widget.smartHome-executeAutomation.error.executeFailed")}</VisuallyHidden>
|
||||
)}
|
||||
{error && <VisuallyHidden role="alert">{t("error.executeFailed")}</VisuallyHidden>}
|
||||
<UnstyledButton
|
||||
onClick={handleClick}
|
||||
disabled={!integrationId || !canInteract || isPending}
|
||||
aria-label={t("widget.smartHome-executeAutomation.spotlightAction.run", { name: options.displayName })}
|
||||
aria-label={t("spotlightAction.run", { name: options.displayName })}
|
||||
style={{
|
||||
cursor: !isEditMode && integrationId && canInteract ? "pointer" : "initial",
|
||||
pointerEvents: isEditMode ? "none" : undefined,
|
||||
}}
|
||||
aria-description={error ? t("widget.smartHome-executeAutomation.error.executeFailed") : undefined}
|
||||
aria-description={error ? t("error.executeFailed") : undefined}
|
||||
w="100%"
|
||||
h="100%"
|
||||
>
|
||||
@@ -124,7 +118,7 @@ export default function SmartHomeTriggerAutomationWidget({
|
||||
<Overlay>
|
||||
<Center w="100%" h="100%" p="xs">
|
||||
<Text size="xs" c="red" ta="center" lineClamp={3}>
|
||||
{t("widget.smartHome-executeAutomation.error.executeFailed")}
|
||||
{t("error.executeFailed")}
|
||||
</Text>
|
||||
</Center>
|
||||
</Overlay>
|
||||
@@ -140,25 +134,21 @@ export default function SmartHomeTriggerAutomationWidget({
|
||||
{displayMode === "advanced" && (
|
||||
<Stack gap={2} align="center">
|
||||
<Text ta="center" size="xs" c="dimmed">
|
||||
{t("widget.smartHome-executeAutomation.advanced.automationId", { id: options.automationId })}
|
||||
{t("advanced.automationId", { id: options.automationId })}
|
||||
</Text>
|
||||
<Text ta="center" size="xs" c={canInteract ? "dimmed" : "orange"}>
|
||||
{t(
|
||||
canInteract
|
||||
? "widget.smartHome-executeAutomation.advanced.ready"
|
||||
: "widget.smartHome-executeAutomation.advanced.noPermission",
|
||||
)}
|
||||
{t(canInteract ? "advanced.ready" : "advanced.noPermission")}
|
||||
</Text>
|
||||
{lastExecutedAt && (
|
||||
<Text ta="center" size="xs" c="dimmed">
|
||||
{t("widget.smartHome-executeAutomation.advanced.lastExecuted", {
|
||||
{t("advanced.lastExecuted", {
|
||||
time: lastExecutedAt.toLocaleTimeString(locale),
|
||||
})}
|
||||
</Text>
|
||||
)}
|
||||
{error && (
|
||||
<Text ta="center" size="xs" c="red">
|
||||
{t("widget.smartHome-executeAutomation.error.executeFailed")}
|
||||
{t("error.executeFailed")}
|
||||
</Text>
|
||||
)}
|
||||
</Stack>
|
||||
|
||||
Reference in new issue
Block a user