diff --git a/client/bun.lockb b/client/bun.lockb index eb505f9..2bd5376 100755 Binary files a/client/bun.lockb and b/client/bun.lockb differ diff --git a/client/package.json b/client/package.json index 52400cf..9dea249 100644 --- a/client/package.json +++ b/client/package.json @@ -32,6 +32,7 @@ "cmdk": "1.0.0", "emoji-picker-react": "^4.12.0", "export-from-json": "^1.7.4", + "i18next": "^23.16.4", "lucide-react": "^0.453.0", "moment": "^2.30.1", "next-themes": "^0.3.0", @@ -39,6 +40,7 @@ "react-dom": "^18.3.1", "react-hook-form": "^7.53.1", "react-hot-toast": "^2.4.1", + "react-i18next": "^15.1.0", "react-markdown": "^9.0.1", "react-router-dom": "^6.27.0", "react-scroll-to-top": "^3.0.0", diff --git a/client/src/components/ChatbotCard.tsx b/client/src/components/ChatbotCard.tsx index 573f80f..e53628c 100644 --- a/client/src/components/ChatbotCard.tsx +++ b/client/src/components/ChatbotCard.tsx @@ -6,6 +6,7 @@ import { Card, CardContent, CardFooter, CardHeader } from "./ui/card"; import { Avatar, AvatarFallback, AvatarImage } from "./ui/avatar"; import { Button } from "./ui/button"; import { Link, useNavigate } from "react-router-dom"; +import { useTranslation } from "react-i18next"; export function ChatbotCard({ chatbot, @@ -16,6 +17,7 @@ export function ChatbotCard({ }) { const shareModel = useShareModal(); const rq = useQueryClient(); + const { t } = useTranslation(); const navigate = useNavigate(); const likeMutation = useMutation({ mutationFn: likeAndReport, @@ -40,7 +42,7 @@ export function ChatbotCard({ {chatbot.latest_version.name}

- Created by @{chatbot.latest_version.modified_by} + {t("created_by")}@{chatbot.latest_version.modified_by}

@@ -64,7 +66,7 @@ export function ChatbotCard({ } > - Like + {t("like")} - Report + {t("report")} navigate(`/chatbot/${chatbot.id}`)} > - Chat + {t("chat")} diff --git a/client/src/components/ImageCard.tsx b/client/src/components/ImageCard.tsx index 000584d..5339bcd 100644 --- a/client/src/components/ImageCard.tsx +++ b/client/src/components/ImageCard.tsx @@ -4,6 +4,7 @@ import { Card, CardContent, CardFooter, CardHeader } from "./ui/card"; import { Button } from "./ui/button"; import { useMutation, useQueryClient } from "@tanstack/react-query"; import { likeAndReport } from "@/lib/queries"; +import { useTranslation } from "react-i18next"; export function ImageCard({ image, @@ -13,6 +14,7 @@ export function ImageCard({ queryKeys: string[]; }) { const qc = useQueryClient(); + const { t } = useTranslation(); const mutation = useMutation({ mutationFn: likeAndReport, onSuccess: () => qc.invalidateQueries({ queryKey: queryKeys }), @@ -73,7 +75,7 @@ export function ImageCard({ > diff --git a/client/src/components/LikeAndReport.tsx b/client/src/components/LikeAndReport.tsx index 8ef5d05..280acc7 100644 --- a/client/src/components/LikeAndReport.tsx +++ b/client/src/components/LikeAndReport.tsx @@ -15,7 +15,6 @@ export function LikeAndReport({ queryKeys: string[]; }) { const qc = useQueryClient(); - const mutation = useMutation({ mutationFn: likeAndReport, onSuccess: () => qc.invalidateQueries({ queryKey: queryKeys }), @@ -59,7 +58,6 @@ export function LikeAndReport({ } > - {/* Display reports count on top of the button */} {reports} diff --git a/client/src/components/Navbar.tsx b/client/src/components/Navbar.tsx index 8c99d16..985cece 100644 --- a/client/src/components/Navbar.tsx +++ b/client/src/components/Navbar.tsx @@ -4,14 +4,33 @@ import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, + DropdownMenuPortal, DropdownMenuSeparator, + DropdownMenuSub, + DropdownMenuSubContent, + DropdownMenuSubTrigger, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { useSettingsModal } from "@/stores/modal-store"; +import { useTranslation } from "react-i18next"; + +const languages = [ + { label: "English", code: "en" }, + { label: "हिन्दी", code: "hi" }, + { label: "Español", code: "es" }, + { label: "Français", code: "fr" }, + { label: "日本語", code: "ja" }, +]; export default function Navbar() { const { user, loading, logout } = useAuth(); const settingsModal = useSettingsModal(); + const { t, i18n } = useTranslation(); + + const changeLanguage = (lng: string) => { + i18n.changeLanguage(lng); + }; + return (