implement i18n

This commit is contained in:
Ben Phelps 2022-09-08 11:48:16 +03:00
parent d25148c8ae
commit c08d4b7b9c
29 changed files with 431 additions and 139 deletions

View file

@ -1,10 +1,11 @@
import useSWR from "swr";
import { FiHardDrive } from "react-icons/fi";
import { BiError } from "react-icons/bi";
import { formatBytes } from "utils/stats-helpers";
import { useTranslation } from "react-i18next";
export default function Disk({ options }) {
const { t } = useTranslation();
const { data, error } = useSWR(`/api/widgets/resources?type=disk&target=${options.disk}`, {
refreshInterval: 1500,
});
@ -14,7 +15,7 @@ export default function Disk({ options }) {
<div className="flex-none flex flex-row items-center justify-center">
<BiError className="text-theme-800 dark:text-theme-200 w-5 h-5" />
<div className="flex flex-col ml-3 text-left font-mono">
<span className="text-theme-800 dark:text-theme-200 text-xs">API Error</span>
<span className="text-theme-800 dark:text-theme-200 text-xs">{t("widget.api_error")}</span>
</div>
</div>
);
@ -38,10 +39,10 @@ export default function Disk({ options }) {
<FiHardDrive className="text-theme-800 dark:text-theme-200 w-5 h-5" />
<div className="flex flex-col ml-3 text-left font-mono ">
<span className="text-theme-800 dark:text-theme-200 text-xs group-hover:hidden">
{formatBytes(data.drive.freeGb * 1024 * 1024 * 1024, 0)} Free
{t("common.bytes", { value: data.drive.freeGb * 1024 * 1024 * 1024 })} {t("resources.free")}
</span>
<span className="text-theme-800 dark:text-theme-200 text-xs hidden group-hover:block">
{formatBytes(data.drive.totalGb * 1024 * 1024 * 1024, 0)} Total
{t("common.bytes", { value: data.drive.totalGb * 1024 * 1024 * 1024 })} {t("resources.total")}
</span>
<div className="w-full bg-gray-200 rounded-full h-1 dark:bg-gray-700">
<div