Skip to content

Commit

Permalink
Add: localization for storage labels in BarChart and Dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
shm11C3 committed Dec 7, 2024
1 parent 1bd21a6 commit 53b2c18
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/components/charts/Bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
ChartTooltipContent,
} from "@/components/ui/chart";
import type { SizeUnit } from "@/rspc/bindings";
import { useTranslation } from "react-i18next";
import { Bar, BarChart, CartesianGrid, XAxis, YAxis } from "recharts";

const chartKey = ["used", "free"] as const;
Expand All @@ -24,16 +25,18 @@ export const StorageBarChart = ({
chartData: StorageBarChartData[];
unit: SizeUnit;
}) => {
const { t } = useTranslation();

const StorageChartConfig: Record<
(typeof chartKey)[number],
{ label: string; color: string }
> = {
used: {
label: `Used (${unit})`,
label: `${t("shared.used")} (${unit})`,
color: "hsl(var(--chart-1))",
},
free: {
label: `Free (${unit})`,
label: `${t("shared.free")} (${unit})`,
color: "hsl(var(--chart-2))",
},
} satisfies ChartConfig;
Expand Down
3 changes: 3 additions & 0 deletions src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@
"clock": "Clock",
"process": "Process",
"reset": "Reset",
"storage": "Storage",
"driveName": "Drive Name",
"driveType": "Drive Type",
"driveTotalSpace": "Drive Total Space",
"driveUsedSpace": "Drive Used Space",
"driveFreeSpace": "Drive Free Space",
"driveFileSystem": "Drive File System",
"used": "Used",
"free": "Free",
"other": "Other"
},

Expand Down
3 changes: 3 additions & 0 deletions src/i18n/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@
"clock": "クロック数",
"process": "プロセス",
"reset": "リセット",
"storage": "ストレージ",
"driveName": "ドライブ名",
"driveType": "ドライブタイプ",
"driveTotalSpace": "ドライブ容量",
"driveUsedSpace": "ドライブ使用量",
"driveFreeSpace": "ドライブ空き容量",
"driveFileSystem": "ファイルシステム",
"used": "使用中",
"free": "空き",
"other": "その他"
},

Expand Down
2 changes: 1 addition & 1 deletion src/template/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ const StorageDataInfo = () => {

return (
<div className="p-2">
<h3 className="text-lg font-bold">Storage</h3>
<h3 className="text-lg font-bold">{t("shared.storage")}</h3>
<div className="flex">
<div className="w-1/2">
{sortedStorage.map((storage) => {
Expand Down

0 comments on commit 53b2c18

Please sign in to comment.