From f7541769dcf953a84ba91d1aa37529e4d1b73dab Mon Sep 17 00:00:00 2001 From: Dan Ditomaso Date: Fri, 23 May 2025 13:34:41 -0400 Subject: [PATCH] fixing translations --- src/components/BatteryStatus.tsx | 6 +++--- src/components/CommandPalette/index.tsx | 4 ++-- src/components/Dialog/DeviceNameDialog.tsx | 4 ++-- src/components/Dialog/LocationResponseDialog.tsx | 4 ++-- .../Dialog/NodeDetailsDialog/NodeDetailsDialog.tsx | 8 ++++---- src/components/Dialog/TracerouteResponseDialog.tsx | 4 ++-- src/components/PageComponents/Connect/BLE.tsx | 4 ++-- src/components/PageComponents/Connect/Serial.tsx | 4 ++-- src/components/PageComponents/Map/NodeDetail.tsx | 4 ++-- src/components/Sidebar.tsx | 4 ++-- src/components/UI/Avatar.tsx | 5 ++++- src/i18n/locales/en.json | 3 ++- src/pages/Dashboard/index.tsx | 2 +- src/pages/Messages.tsx | 6 +++--- src/pages/Nodes.tsx | 4 ++-- 15 files changed, 35 insertions(+), 31 deletions(-) diff --git a/src/components/BatteryStatus.tsx b/src/components/BatteryStatus.tsx index ad0270cb..cf2d2523 100644 --- a/src/components/BatteryStatus.tsx +++ b/src/components/BatteryStatus.tsx @@ -81,9 +81,9 @@ const BatteryStatus: React.FC = ({ deviceMetrics }) => { const iconClassName = currentState.className; const statusText = currentState.text(batteryLevel); - const voltageTitle = `${voltage?.toPrecision(3) ?? t("common_unknown")} ${ - t("common_unit_volts") - }`; + const voltageTitle = `${ + voltage?.toPrecision(3) ?? t("common_unknown_short") + } ${t("common_unit_volts")}`; return (
{ icon: ArrowLeftRightIcon, subItems: getDevices().map((device) => ({ label: getNode(device.hardware.myNodeNum)?.user?.longName ?? - t("common_unknown"), // Or a more specific key for node name + t("common_unknown_short"), // Or a more specific key for node name icon: ( ), action() { diff --git a/src/components/Dialog/DeviceNameDialog.tsx b/src/components/Dialog/DeviceNameDialog.tsx index bd33bda1..bff4f98d 100644 --- a/src/components/Dialog/DeviceNameDialog.tsx +++ b/src/components/Dialog/DeviceNameDialog.tsx @@ -38,8 +38,8 @@ export const DeviceNameDialog = ({ const myNode = getNode(hardware.myNodeNum); const defaultValues = { - longName: myNode?.user?.longName ?? "Unknown", - shortName: myNode?.user?.shortName ?? "??", + longName: myNode?.user?.longName ?? t("common_unknown_long"), + shortName: myNode?.user?.shortName ?? t("common_unknown_short"), }; const { getValues, setValue, reset, control, handleSubmit } = useForm({ diff --git a/src/components/Dialog/LocationResponseDialog.tsx b/src/components/Dialog/LocationResponseDialog.tsx index 1e696acb..670f5d6f 100644 --- a/src/components/Dialog/LocationResponseDialog.tsx +++ b/src/components/Dialog/LocationResponseDialog.tsx @@ -27,11 +27,11 @@ export const LocationResponseDialog = ({ const from = getNode(location?.from ?? 0); const longName = from?.user?.longName ?? - (from ? `!${numberToHexUnpadded(from?.num)}` : t("common_unknown")); + (from ? `!${numberToHexUnpadded(from?.num)}` : t("common_unknown_short")); const shortName = from?.user?.shortName ?? (from ? `${numberToHexUnpadded(from?.num).substring(0, 4)}` - : t("common_unknown")); + : t("common_unknown_short")); return ( diff --git a/src/components/Dialog/NodeDetailsDialog/NodeDetailsDialog.tsx b/src/components/Dialog/NodeDetailsDialog/NodeDetailsDialog.tsx index 2466bab3..1504c04f 100644 --- a/src/components/Dialog/NodeDetailsDialog/NodeDetailsDialog.tsx +++ b/src/components/Dialog/NodeDetailsDialog/NodeDetailsDialog.tsx @@ -172,8 +172,8 @@ export const NodeDetailsDialog = ({ {t("dialog_nodeDetails_titlePrefix")} - {node.user?.longName ?? t("common_unknown")} ( - {node.user?.shortName ?? t("common_unknown")}) + {node.user?.longName ?? t("common_unknown_short")} ( + {node.user?.shortName ?? t("common_unknown_short")}) @@ -275,7 +275,7 @@ export const NodeDetailsDialog = ({

{t("dialog_nodeDetails_label_hardware")} {(Protobuf.Mesh.HardwareModel[node.user?.hwModel ?? 0] ?? - t("common_unknown")) + t("common_unknown_short")) .replace(/_/g, " ")}

@@ -322,7 +322,7 @@ export const NodeDetailsDialog = ({ )} ) - :

{t("common_unknown")}

} + :

{t("common_unknown_short")}

} ); diff --git a/src/components/PageComponents/Connect/Serial.tsx b/src/components/PageComponents/Connect/Serial.tsx index 1b258b6e..720bb377 100644 --- a/src/components/PageComponents/Connect/Serial.tsx +++ b/src/components/PageComponents/Connect/Serial.tsx @@ -56,8 +56,8 @@ export const Serial = (
{serialPorts.map((port, index) => { const { usbProductId, usbVendorId } = port.getInfo(); - const vendor = usbVendorId ?? t("common_unknown"); - const product = usbProductId ?? t("common_unknown"); + const vendor = usbVendorId ?? t("common_unknown_short"); + const product = usbProductId ?? t("common_unknown_short"); return (
@@ -250,7 +250,7 @@ export const Sidebar = ({ children }: SidebarProps) => { {t("sidebar_deviceInfo.firmwareVersion", { version: myMetadata?.firmwareVersion ?? - t("common_unknown"), + t("common_unknown_short"), })} diff --git a/src/components/UI/Avatar.tsx b/src/components/UI/Avatar.tsx index 90a0f20e..678c2df3 100644 --- a/src/components/UI/Avatar.tsx +++ b/src/components/UI/Avatar.tsx @@ -7,6 +7,7 @@ import { TooltipProvider, TooltipTrigger, } from "@components/UI/Tooltip.tsx"; +import { useTranslation } from "react-i18next"; type RGBColor = { r: number; @@ -73,6 +74,8 @@ export const Avatar = ({ showFavorite = false, className, }: AvatarProps) => { + const { t } = useTranslation(); + const sizes = { sm: "size-10 text-xs font-light", lg: "size-16 text-lg", @@ -82,7 +85,7 @@ export const Avatar = ({ const bgColor = getColorFromText(safeText); const isLight = ColorUtils.isLight(bgColor); const textColor = isLight ? "#000000" : "#FFFFFF"; - const initials = safeText?.slice(0, 4) ?? "UNK"; + const initials = safeText?.slice(0, 4) ?? t("common_unknown_short"); return (
{

{device.getNode(device.hardware.myNodeNum)?.user - ?.longName ?? "UNK"} + ?.longName ?? t("common_unknown_short")}

{device.connection?.connType === "ble" && ( diff --git a/src/pages/Messages.tsx b/src/pages/Messages.tsx index 5ad16b8e..dd516366 100644 --- a/src/pages/Messages.tsx +++ b/src/pages/Messages.tsx @@ -237,7 +237,7 @@ export const MessagesPage = () => { 0 ? node.unreadCount : undefined} active={activeChat === node.num && chatType === MessageType.Direct} @@ -248,7 +248,7 @@ export const MessagesPage = () => { }} > { const pageTitleChatName = useMemo(() => { if (isBroadcast && currentChannel) return getChannelName(currentChannel); if (isDirect && otherNode) { - return otherNode.user?.longName ?? t("common_unknown"); + return otherNode.user?.longName ?? t("common_unknown_short"); } return t("messages_title_default"); }, [isBroadcast, currentChannel, isDirect, otherNode, t]); diff --git a/src/pages/Nodes.tsx b/src/pages/Nodes.tsx index 9e2880f8..5e7b7588 100644 --- a/src/pages/Nodes.tsx +++ b/src/pages/Nodes.tsx @@ -169,7 +169,7 @@ const NodesPage = (): JSX.Element => { rows={filteredNodes.map((node) => [
@@ -227,7 +227,7 @@ const NodesPage = (): JSX.Element => { {base16 .stringify(node.user?.macaddr ?? []) .match(/.{1,2}/g) - ?.join(":") ?? t("common_unknown")} + ?.join(":") ?? t("common_unknown_short")} , ])} />