From 313f3f540f0cce6ffb8bd04b7677514370a0d425 Mon Sep 17 00:00:00 2001 From: luizakp Date: Wed, 6 Mar 2024 18:15:45 -0300 Subject: [PATCH] chore: use useTranslate from react lib --- src/components/Cmdk.tsx | 12 ++++-------- src/components/DataTable/DataTableToolbar.tsx | 7 +++++-- src/components/RichTextEditor/index.tsx | 4 ++++ src/locales/en/translation.json | 4 +++- src/locales/pt-BR/translation.json | 4 +++- 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/components/Cmdk.tsx b/src/components/Cmdk.tsx index 5bb4ea7..2aa0e0d 100644 --- a/src/components/Cmdk.tsx +++ b/src/components/Cmdk.tsx @@ -1,8 +1,7 @@ import { CircleIcon, FileIcon } from "@radix-ui/react-icons"; import * as React from "react"; import { useNavigate } from "react-router-dom"; -import { Trans } from "react-i18next"; -import { t } from "i18next"; +import { Trans, useTranslation } from "react-i18next"; import { Button, CommandDialog, @@ -15,13 +14,10 @@ import { } from "#/components/ui"; import { cn } from "#/lib/utils"; -export function CommandMenu({ - commands, - placeholder = "Busca global", - ...props -}) { +export function CommandMenu({ commands, ...props }) { const navigate = useNavigate(); const [open, setOpen] = React.useState(false); + const { t } = useTranslation(); React.useEffect(() => { const down = (e) => { @@ -51,7 +47,7 @@ export function CommandMenu({ onClick={() => setOpen(true)} {...props} > - {placeholder} + {t("Global search")} K diff --git a/src/components/DataTable/DataTableToolbar.tsx b/src/components/DataTable/DataTableToolbar.tsx index b5e14e2..a26ba7f 100644 --- a/src/components/DataTable/DataTableToolbar.tsx +++ b/src/components/DataTable/DataTableToolbar.tsx @@ -1,6 +1,7 @@ import { Cross2Icon } from "@radix-ui/react-icons"; import React, { useEffect, useRef } from "react"; -import { t } from "i18next"; + +import { useTranslation } from "react-i18next"; import { Button, Input } from "#/components/ui"; import { DataTableFacetedFilter } from "./DataTableFacetedFilter"; @@ -39,11 +40,13 @@ export function DataTableToolbar({ } }, [filters, table]); + const { t } = useTranslation(); + return (
table.getColumn(searchKey)?.setFilterValue(event.target.value) diff --git a/src/components/RichTextEditor/index.tsx b/src/components/RichTextEditor/index.tsx index 3205c9d..d69094a 100644 --- a/src/components/RichTextEditor/index.tsx +++ b/src/components/RichTextEditor/index.tsx @@ -1,6 +1,7 @@ import "./styles.css"; import React, { Suspense, lazy } from "react"; +import { useTranslation } from "react-i18next"; import { useTheme } from "#/components/ThemeToggle/context"; const JoditEditor = lazy(() => import("jodit-react")); @@ -46,6 +47,7 @@ const EDITOR_BUTTONS = [ export function RichTextEditor({ initialValue, onChange }) { const { theme } = useTheme(); + const { t } = useTranslation(); return (
@@ -53,6 +55,8 @@ export function RichTextEditor({ initialValue, onChange }) {