Browse Source

fixing translations

pull/627/head
Dan Ditomaso 1 year ago
parent
commit
f543d6c057
  1. 12
      src/components/BatteryStatus.tsx
  2. 4
      src/components/CommandPalette/index.tsx
  3. 4
      src/components/Dialog/LocationResponseDialog.tsx
  4. 8
      src/components/Dialog/NodeDetailsDialog/NodeDetailsDialog.tsx
  5. 4
      src/components/Dialog/TracerouteResponseDialog.tsx
  6. 4
      src/components/PageComponents/Connect/Serial.tsx
  7. 10
      src/components/PageComponents/Map/NodeDetail.tsx
  8. 2
      src/components/PageComponents/Messages/ChannelChat.tsx
  9. 8
      src/components/PageComponents/Messages/MessageActionsMenu.tsx
  10. 20
      src/components/Sidebar.tsx
  11. 4
      src/components/generic/Filter/FilterControl.tsx
  12. 3
      src/i18n/locales/en.json
  13. 2
      src/pages/Channels.tsx
  14. 6
      src/pages/Messages.tsx
  15. 4
      src/pages/Nodes.tsx

12
src/components/BatteryStatus.tsx

@ -32,25 +32,25 @@ const getBatteryStates = (
condition: (level) => level > 100, condition: (level) => level > 100,
Icon: PlugZapIcon, Icon: PlugZapIcon,
className: "text-gray-500", className: "text-gray-500",
text: () => t("common.batteryStatus.pluggedIn"), text: () => t("common_batteryStatus.pluggedIn"),
}, },
{ {
condition: (level) => level > 80, condition: (level) => level > 80,
Icon: BatteryFullIcon, Icon: BatteryFullIcon,
className: "text-green-500", className: "text-green-500",
text: (level) => t("common.batteryStatus.charging", { level }), text: (level) => t("common_batteryStatus.charging", { level }),
}, },
{ {
condition: (level) => level > 20, condition: (level) => level > 20,
Icon: BatteryMediumIcon, Icon: BatteryMediumIcon,
className: "text-yellow-500", className: "text-yellow-500",
text: (level) => t("common.batteryStatus.charging", { level }), text: (level) => t("common_batteryStatus.charging", { level }),
}, },
{ {
condition: () => true, condition: () => true,
Icon: BatteryLowIcon, Icon: BatteryLowIcon,
className: "text-red-500", className: "text-red-500",
text: (level) => t("common.batteryStatus.charging", { level }), text: (level) => t("common_batteryStatus.charging", { level }),
}, },
]; ];
}; };
@ -81,7 +81,7 @@ const BatteryStatus: React.FC<BatteryStatusProps> = ({ deviceMetrics }) => {
const iconClassName = currentState.className; const iconClassName = currentState.className;
const statusText = currentState.text(batteryLevel); const statusText = currentState.text(batteryLevel);
const voltageTitle = `${voltage?.toPrecision(3) ?? t("common.unknown")} ${ const voltageTitle = `${voltage?.toPrecision(3) ?? t("common_unknown")} ${
t("common_unit_volts") t("common_unit_volts")
}`; }`;
@ -91,7 +91,7 @@ const BatteryStatus: React.FC<BatteryStatusProps> = ({ deviceMetrics }) => {
title={voltageTitle} title={voltageTitle}
> >
<BatteryIcon size={22} className={iconClassName} /> <BatteryIcon size={22} className={iconClassName} />
<Subtle aria-label={t("common.batteryStatus.title")}> <Subtle aria-label={t("common_batteryStatus.title")}>
{statusText} {statusText}
</Subtle> </Subtle>
</div> </div>

4
src/components/CommandPalette/index.tsx

@ -120,11 +120,11 @@ export const CommandPalette = () => {
icon: ArrowLeftRightIcon, icon: ArrowLeftRightIcon,
subItems: getDevices().map((device) => ({ subItems: getDevices().map((device) => ({
label: getNode(device.hardware.myNodeNum)?.user?.longName ?? label: getNode(device.hardware.myNodeNum)?.user?.longName ??
t("common.unknown"), // Or a more specific key for node name t("common_unknown"), // Or a more specific key for node name
icon: ( icon: (
<Avatar <Avatar
text={getNode(device.hardware.myNodeNum)?.user?.shortName ?? text={getNode(device.hardware.myNodeNum)?.user?.shortName ??
t("common.unknown")} // Or a more specific key t("common_unknown")} // Or a more specific key
/> />
), ),
action() { action() {

4
src/components/Dialog/LocationResponseDialog.tsx

@ -27,11 +27,11 @@ export const LocationResponseDialog = ({
const from = getNode(location?.from ?? 0); const from = getNode(location?.from ?? 0);
const longName = from?.user?.longName ?? const longName = from?.user?.longName ??
(from ? `!${numberToHexUnpadded(from?.num)}` : t("common.unknown")); (from ? `!${numberToHexUnpadded(from?.num)}` : t("common_unknown"));
const shortName = from?.user?.shortName ?? const shortName = from?.user?.shortName ??
(from (from
? `${numberToHexUnpadded(from?.num).substring(0, 4)}` ? `${numberToHexUnpadded(from?.num).substring(0, 4)}`
: t("common.unknown")); : t("common_unknown"));
return ( return (
<Dialog open={open} onOpenChange={onOpenChange}> <Dialog open={open} onOpenChange={onOpenChange}>

8
src/components/Dialog/NodeDetailsDialog/NodeDetailsDialog.tsx

@ -172,8 +172,8 @@ export const NodeDetailsDialog = ({
<DialogHeader> <DialogHeader>
<DialogTitle> <DialogTitle>
{t("dialog_nodeDetails_titlePrefix")} {t("dialog_nodeDetails_titlePrefix")}
{node.user?.longName ?? t("common.unknown")} ( {node.user?.longName ?? t("common_unknown")} (
{node.user?.shortName ?? t("common.unknown")}) {node.user?.shortName ?? t("common_unknown")})
</DialogTitle> </DialogTitle>
</DialogHeader> </DialogHeader>
<DialogFooter> <DialogFooter>
@ -275,7 +275,7 @@ export const NodeDetailsDialog = ({
<p> <p>
{t("dialog_nodeDetails_label_hardware")} {t("dialog_nodeDetails_label_hardware")}
{(Protobuf.Mesh.HardwareModel[node.user?.hwModel ?? 0] ?? {(Protobuf.Mesh.HardwareModel[node.user?.hwModel ?? 0] ??
t("common.unknown")) t("common_unknown"))
.replace(/_/g, " ")} .replace(/_/g, " ")}
</p> </p>
</div> </div>
@ -322,7 +322,7 @@ export const NodeDetailsDialog = ({
)} )}
</> </>
) )
: <p>{t("common.unknown")}</p>} : <p>{t("common_unknown")}</p>}
<Button <Button
onClick={handleRequestPosition} onClick={handleRequestPosition}
name="requestPosition" name="requestPosition"

4
src/components/Dialog/TracerouteResponseDialog.tsx

@ -32,11 +32,11 @@ export const TracerouteResponseDialog = ({
const snrBack = (traceroute?.data.snrBack ?? []).map((snr) => snr / 4); const snrBack = (traceroute?.data.snrBack ?? []).map((snr) => snr / 4);
const from = getNode(traceroute?.from ?? 0); const from = getNode(traceroute?.from ?? 0);
const longName = from?.user?.longName ?? const longName = from?.user?.longName ??
(from ? `!${numberToHexUnpadded(from?.num)}` : t("common.unknown")); (from ? `!${numberToHexUnpadded(from?.num)}` : t("common_unknown"));
const shortName = from?.user?.shortName ?? const shortName = from?.user?.shortName ??
(from (from
? `${numberToHexUnpadded(from?.num).substring(0, 4)}` ? `${numberToHexUnpadded(from?.num).substring(0, 4)}`
: t("common.unknown")); : t("common_unknown"));
const to = getNode(traceroute?.to ?? 0); const to = getNode(traceroute?.to ?? 0);
return ( return (
<Dialog open={open} onOpenChange={onOpenChange}> <Dialog open={open} onOpenChange={onOpenChange}>

4
src/components/PageComponents/Connect/Serial.tsx

@ -56,8 +56,8 @@ export const Serial = (
<div className="flex h-48 flex-col gap-2 overflow-y-auto"> <div className="flex h-48 flex-col gap-2 overflow-y-auto">
{serialPorts.map((port, index) => { {serialPorts.map((port, index) => {
const { usbProductId, usbVendorId } = port.getInfo(); const { usbProductId, usbVendorId } = port.getInfo();
const vendor = usbVendorId ?? t("common.unknown"); const vendor = usbVendorId ?? t("common_unknown");
const product = usbProductId ?? t("common.unknown"); const product = usbProductId ?? t("common_unknown");
return ( return (
<Button <Button
key={`${vendor}-${product}-${index}`} key={`${vendor}-${product}-${index}`}

10
src/components/PageComponents/Map/NodeDetail.tsx

@ -38,15 +38,15 @@ export const NodeDetail = ({ node }: NodeDetailProps) => {
const { setChatType, setActiveChat } = useMessageStore(); const { setChatType, setActiveChat } = useMessageStore();
const { t } = useTranslation(); const { t } = useTranslation();
const { setActivePage } = useDevice(); const { setActivePage } = useDevice();
const name = node.user?.longName ?? t("common.unknown"); const name = node.user?.longName ?? t("common_unknown");
const shortName = node.user?.shortName ?? t("common.unknown"); const shortName = node.user?.shortName ?? t("common_unknown");
const hwModel = node.user?.hwModel ?? 0; const hwModel = node.user?.hwModel ?? 0;
const rawHardwareType = Protobuf.Mesh.HardwareModel[hwModel] as const rawHardwareType = Protobuf.Mesh.HardwareModel[hwModel] as
| keyof typeof Protobuf.Mesh.HardwareModel | keyof typeof Protobuf.Mesh.HardwareModel
| undefined; | undefined;
const hardwareType = rawHardwareType const hardwareType = rawHardwareType
? rawHardwareType === "UNSET" ? rawHardwareType === "UNSET"
? t("common.unset") ? t("common_unset")
: rawHardwareType.replaceAll("_", " ") : rawHardwareType.replaceAll("_", " ")
: `${hwModel}`; : `${hwModel}`;
function handleDirectMessage() { function handleDirectMessage() {
@ -121,7 +121,7 @@ export const NodeDetail = ({ node }: NodeDetailProps) => {
<div> <div>
<Heading as="h5">{name}</Heading> <Heading as="h5">{name}</Heading>
{hardwareType !== t("common.unset") && <Subtle>{hardwareType} {hardwareType !== t("common_unset") && <Subtle>{hardwareType}
</Subtle>} </Subtle>}
{!!node.deviceMetrics?.batteryLevel && ( {!!node.deviceMetrics?.batteryLevel && (
@ -223,7 +223,7 @@ export const NodeDetail = ({ node }: NodeDetailProps) => {
{Math.min(Math.max((node.snr + 10) * 5, 0), 100)}% {Math.min(Math.max((node.snr + 10) * 5, 0), 100)}%
<Dot /> <Dot />
{(node.snr + 10) * 5} {(node.snr + 10) * 5}
{t("common.rawUnit")} {t("common_rawUnit")}
</Mono> </Mono>
</div> </div>
)} )}

2
src/components/PageComponents/Messages/ChannelChat.tsx

@ -12,7 +12,7 @@ const EmptyState = () => {
return ( return (
<div className="flex flex-1 flex-col place-content-center place-items-center p-8 text-slate-500 dark:text-slate-400"> <div className="flex flex-1 flex-col place-content-center place-items-center p-8 text-slate-500 dark:text-slate-400">
<InboxIcon className="mb-2 h-8 w-8" /> <InboxIcon className="mb-2 h-8 w-8" />
<span className="text-sm">{t("messages.empty")}</span> <span className="text-sm">{t("messages_empty")}</span>
</div> </div>
); );
}; };

8
src/components/PageComponents/Messages/MessageActionsMenu.tsx

@ -50,7 +50,7 @@ export const MessageActionsMenu = ({
<TooltipTrigger asChild> <TooltipTrigger asChild>
<button <button
type="button" type="button"
aria-label={t("messages.actionsMenu.addReactionLabel")} aria-label={t("messages_actionsMenu_addReactionLabel")}
onClick={(e) => { onClick={(e) => {
e.stopPropagation(); e.stopPropagation();
if (onAddReaction) { if (onAddReaction) {
@ -63,7 +63,7 @@ export const MessageActionsMenu = ({
</button> </button>
</TooltipTrigger> </TooltipTrigger>
<TooltipContent className="bg-gray-800 text-white px-2 py-1 rounded text-xs"> <TooltipContent className="bg-gray-800 text-white px-2 py-1 rounded text-xs">
{t("messages.actionsMenu.addReactionLabel")} {t("messages_actionsMenu_addReactionLabel")}
<TooltipArrow className="fill-gray-800" /> <TooltipArrow className="fill-gray-800" />
</TooltipContent> </TooltipContent>
</Tooltip> </Tooltip>
@ -72,7 +72,7 @@ export const MessageActionsMenu = ({
<TooltipTrigger asChild> <TooltipTrigger asChild>
<button <button
type="button" type="button"
aria-label={t("messages.actionsMenu.replyLabel")} aria-label={t("messages_actionsMenu_replyLabel")}
onClick={(e) => { onClick={(e) => {
e.stopPropagation(); e.stopPropagation();
if (onReply) { if (onReply) {
@ -85,7 +85,7 @@ export const MessageActionsMenu = ({
</button> </button>
</TooltipTrigger> </TooltipTrigger>
<TooltipContent className="bg-gray-800 text-white px-2 py-1 rounded text-xs"> <TooltipContent className="bg-gray-800 text-white px-2 py-1 rounded text-xs">
{t("messages.actionsMenu.replyLabel")} {t("messages_actionsMenu_replyLabel")}
<TooltipArrow className="fill-gray-800" /> <TooltipArrow className="fill-gray-800" />
</TooltipContent> </TooltipContent>
</Tooltip> </Tooltip>

20
src/components/Sidebar.tsx

@ -42,8 +42,8 @@ const CollapseToggleButton = () => {
const { isCollapsed, toggleSidebar } = useSidebar(); const { isCollapsed, toggleSidebar } = useSidebar();
const { t } = useTranslation(); const { t } = useTranslation();
const buttonLabel = isCollapsed const buttonLabel = isCollapsed
? t("sidebar.collapseToggle.button_open") ? t("sidebar_collapseToggle-button_open")
: t("sidebar.collapseToggle.button_close"); : t("sidebar_collapseToggle_button_close");
return ( return (
<button <button
@ -134,7 +134,7 @@ export const Sidebar = ({ children }: SidebarProps) => {
> >
<img <img
src="Logo.svg" src="Logo.svg"
alt="Meshtastic Logo" alt={t("sidebar_app_title_alt")}
className="size-10 flex-shrink-0 rounded-xl" className="size-10 flex-shrink-0 rounded-xl"
/> />
<h2 <h2
@ -146,7 +146,7 @@ export const Sidebar = ({ children }: SidebarProps) => {
: "opacity-100 max-w-xs visible ml-2", : "opacity-100 max-w-xs visible ml-2",
)} )}
> >
{t("common.header")} {t("common_header")}
</h2> </h2>
</div> </div>
@ -188,7 +188,7 @@ export const Sidebar = ({ children }: SidebarProps) => {
isCollapsed ? "opacity-0 invisible" : "opacity-100 visible", isCollapsed ? "opacity-0 invisible" : "opacity-100 visible",
)} )}
> >
{t("common.loading")} {t("common_loading")}
</Subtle> </Subtle>
</div> </div>
) )
@ -236,9 +236,9 @@ export const Sidebar = ({ children }: SidebarProps) => {
className="text-gray-500 dark:text-gray-400 w-4 flex-shrink-0" className="text-gray-500 dark:text-gray-400 w-4 flex-shrink-0"
/> />
<Subtle> <Subtle>
{t("sidebar.deviceInfo.volts", { {t("sidebar_deviceInfo.volts", {
voltage: myNode.deviceMetrics?.voltage?.toPrecision(3) ?? voltage: myNode.deviceMetrics?.voltage?.toPrecision(3) ??
t("common.unknown"), t("common_unknown"),
})} })}
</Subtle> </Subtle>
</div> </div>
@ -248,9 +248,9 @@ export const Sidebar = ({ children }: SidebarProps) => {
className="text-gray-500 dark:text-gray-400 w-4 flex-shrink-0" className="text-gray-500 dark:text-gray-400 w-4 flex-shrink-0"
/> />
<Subtle> <Subtle>
{t("sidebar.deviceInfo.firmwareVersion", { {t("sidebar_deviceInfo.firmwareVersion", {
version: myMetadata?.firmwareVersion ?? version: myMetadata?.firmwareVersion ??
t("common.unknown"), t("common_unknown"),
})} })}
</Subtle> </Subtle>
</div> </div>
@ -266,7 +266,7 @@ export const Sidebar = ({ children }: SidebarProps) => {
> >
<button <button
type="button" type="button"
aria-label={t("sidebar.deviceInfo.button_editDeviceName")} aria-label={t("sidebar_deviceInfo.button_editDeviceName")}
className="p-1 rounded transition-colors cursor-pointer hover:text-accent" className="p-1 rounded transition-colors cursor-pointer hover:text-accent"
onClick={() => setDialogOpen("deviceName", true)} onClick={() => setDialogOpen("deviceName", true)}
> >

4
src/components/generic/Filter/FilterControl.tsx

@ -278,7 +278,7 @@ export function FilterControl({
<> <>
{t("filter_control_slider_batteryLevel_labelText", { {t("filter_control_slider_batteryLevel_labelText", {
value: localFilterState.batteryLevel[0] === 101 value: localFilterState.batteryLevel[0] === 101
? t("common.batteryStatus.pluggedIn") ? t("common_batteryStatus.pluggedIn")
: localFilterState.batteryLevel[0], : localFilterState.batteryLevel[0],
})} })}
{localFilterState.batteryLevel[0] !== {localFilterState.batteryLevel[0] !==
@ -286,7 +286,7 @@ export function FilterControl({
<> <>
{" – "} {" – "}
{localFilterState.batteryLevel[1] === 101 {localFilterState.batteryLevel[1] === 101
? t("common.batteryStatus.pluggedIn") ? t("common_batteryStatus.pluggedIn")
: localFilterState.batteryLevel[1]} : localFilterState.batteryLevel[1]}
</> </>
)} )}

3
src/i18n/locales/en.json

@ -1,6 +1,6 @@
{ {
"common_title": "Meshtastic Web", "common_title": "Meshtastic Web",
"common_header": "Meshtastic", "common_app": "Meshtastic",
"common_description": "Meshtastic Web Client", "common_description": "Meshtastic Web Client",
"common_button_close": "Close", "common_button_close": "Close",
"common_button_ok": "OK", "common_button_ok": "OK",
@ -147,6 +147,7 @@
"sidebar_collapseToggle_button_open": "Open sidebar", "sidebar_collapseToggle_button_open": "Open sidebar",
"sidebar_collapseToggle_button_close": "Close sidebar", "sidebar_collapseToggle_button_close": "Close sidebar",
"sidebar_app_title_alt": "Meshtastic Logo",
"sidebar_deviceInfo_volts": "{{voltage}} volts", "sidebar_deviceInfo_volts": "{{voltage}} volts",
"sidebar_deviceInfo_firmwareVersion": "v{{version}}", "sidebar_deviceInfo_firmwareVersion": "v{{version}}",
"sidebar_deviceInfo_button_editDeviceName": "Edit device name", "sidebar_deviceInfo_button_editDeviceName": "Edit device name",

2
src/pages/Channels.tsx

@ -40,7 +40,7 @@ const ChannelsPage = () => {
? t("channel_page_title", { ? t("channel_page_title", {
channelName: getChannelName(currentChannel), channelName: getChannelName(currentChannel),
}) })
: t("common.loading")} : t("common_loading")}
actions={[ actions={[
{ {
key: "search", key: "search",

6
src/pages/Messages.tsx

@ -237,7 +237,7 @@ export const MessagesPage = () => {
<SidebarButton <SidebarButton
key={node.num} key={node.num}
preventCollapse preventCollapse
label={node.user?.longName ?? t("common.unknown")} label={node.user?.longName ?? t("common_unknown")}
count={node.unreadCount > 0 ? node.unreadCount : undefined} count={node.unreadCount > 0 ? node.unreadCount : undefined}
active={activeChat === node.num && active={activeChat === node.num &&
chatType === MessageType.Direct} chatType === MessageType.Direct}
@ -248,7 +248,7 @@ export const MessagesPage = () => {
}} }}
> >
<Avatar <Avatar
text={node.user?.shortName ?? t("common.unknown")} text={node.user?.shortName ?? t("common_unknown")}
className={cn(hasNodeError(node.num) && "text-red-500")} className={cn(hasNodeError(node.num) && "text-red-500")}
showError={hasNodeError(node.num)} showError={hasNodeError(node.num)}
showFavorite={node.isFavorite} showFavorite={node.isFavorite}
@ -274,7 +274,7 @@ export const MessagesPage = () => {
const pageTitleChatName = useMemo(() => { const pageTitleChatName = useMemo(() => {
if (isBroadcast && currentChannel) return getChannelName(currentChannel); if (isBroadcast && currentChannel) return getChannelName(currentChannel);
if (isDirect && otherNode) { if (isDirect && otherNode) {
return otherNode.user?.longName ?? t("common.unknown"); return otherNode.user?.longName ?? t("common_unknown");
} }
return t("messages_title_default"); return t("messages_title_default");
}, [isBroadcast, currentChannel, isDirect, otherNode, t]); }, [isBroadcast, currentChannel, isDirect, otherNode, t]);

4
src/pages/Nodes.tsx

@ -169,7 +169,7 @@ const NodesPage = (): JSX.Element => {
rows={filteredNodes.map((node) => [ rows={filteredNodes.map((node) => [
<div key={node.num}> <div key={node.num}>
<Avatar <Avatar
text={node.user?.shortName ?? t("common.unknown")} text={node.user?.shortName ?? t("common_unknown")}
showFavorite={node.isFavorite} showFavorite={node.isFavorite}
showError={hasNodeError(node.num)} showError={hasNodeError(node.num)}
/> />
@ -227,7 +227,7 @@ const NodesPage = (): JSX.Element => {
{base16 {base16
.stringify(node.user?.macaddr ?? []) .stringify(node.user?.macaddr ?? [])
.match(/.{1,2}/g) .match(/.{1,2}/g)
?.join(":") ?? t("common.unknown")} ?.join(":") ?? t("common_unknown")}
</Mono>, </Mono>,
])} ])}
/> />

Loading…
Cancel
Save