diff --git a/messages/en.json b/messages/en.json index 1b0553d..96e7a8b 100644 --- a/messages/en.json +++ b/messages/en.json @@ -7,6 +7,69 @@ "Sign up": "Sign up" }, "sign-up-form": { - "title": "Hello world!" + "title": "Hello world!", + "enter-your-email-below-to-sign-up-to-your-account": "enter-your-email-below-to-sign-up-to-your-account", + "sign-up-to-your-account": "Sign up to your account", + "or": "Or", + "already-have-an-account": "Already have an account?", + "sign-in": "Sign in" + }, + "appearance-settings": { + "choose-a-theme": "Choose a theme", + "toggle-theme": "Toggle theme", + "light": "Light", + "dark": "Dark", + "system": "System" + }, + "avatar-button": { + "log-in": "Log In", + "account": "Account", + "log-out": "Log out" + }, + "email": "Email", + "password": "Password", + "GithubSignInForm": { + "continue-with-github": "Continue with GitHub" + }, + "nav": { + "platform": "Platform", + "projects": "Projects", + "more": "More", + "view-project": "View Project", + "share-project": "Share Project", + "delete-project": "Delete Project", + "upgrade-to-pro": "Upgrade to Pro", + "billing": "Billing", + "notifications": "Notifications", + "home": "Home" + }, + "run-code": { + "run": "Run", + "run-code": "Run Code", + "running": "Running..." + }, + "settings": { + "settings": "Settings", + "appearance": "Appearance", + "language-and-region": "Language & region", + "code-editor": "Code Editor", + "advanced": "Advanced", + "customize-your-settings-here": "Customize your settings here." + }, + "submissions": { + "index": "Index", + "status": "Status", + "language": "Language", + "time": "Time", + "memory": "Memory", + "submitted": "Submitted" + }, + "teams": { + "teams": "Teams", + "add-team": "Add team" + }, + "test": { + "case": "Case", + "failed-to-submit-the-form-please-try-again": "Failed to submit the form. Please try again." } -} \ No newline at end of file +} diff --git a/messages/zh.json b/messages/zh.json index c3baa96..f90e32c 100644 --- a/messages/zh.json +++ b/messages/zh.json @@ -7,6 +7,69 @@ "Sign up": "注册" }, "sign-up-form": { - "title": "Hello world!" + "title": "Hello world!", + "already-have-an-account": "已经有账号了?", + "enter-your-email-below-to-sign-up-to-your-account": "在下面输入您的电子邮件以注册您的帐户", + "or": "或", + "sign-in": "登录", + "sign-up-to-your-account": "注册您的帐户" + }, + "appearance-settings": { + "dark": "暗", + "light": "亮", + "system": "系统", + "choose-a-theme": "选择一个主题", + "toggle-theme": "切换主题" + }, + "nav": { + "platform": "平台", + "projects": "项目", + "share-project": "共享项目", + "upgrade-to-pro": "升级到专业版", + "view-project": "查看项目", + "more": "更多", + "notifications": "通知", + "billing": "账务", + "delete-project": "删除项目", + "home": "主页" + }, + "GithubSignInForm": { + "continue-with-github": "继续使用GitHub" + }, + "avatar-button": { + "account": "账户", + "log-in": "登录", + "log-out": "注销" + }, + "password": "密码", + "run-code": { + "run-code": "运行代码", + "run": "运行", + "running": "正在运行。。。" + }, + "submissions": { + "status": "状态", + "submitted": "提交", + "time": "时间", + "language": "语言", + "memory": "内存", + "index": "指数" + }, + "teams": { + "teams": "团队", + "add-team": "添加团队" + }, + "email": "电子邮件", + "settings": { + "advanced": "高级", + "appearance": "外貌", + "code-editor": "代码编辑器", + "customize-your-settings-here": "在此处自定义您的设置。", + "language-and-region": "语言和地区", + "settings": "设置" + }, + "test": { + "case": "样例", + "failed-to-submit-the-form-please-try-again": "提交失败。请重试。" } -} \ No newline at end of file +} diff --git a/src/components/appearance-settings.tsx b/src/components/appearance-settings.tsx index ad5c0a7..6513a92 100644 --- a/src/components/appearance-settings.tsx +++ b/src/components/appearance-settings.tsx @@ -1,9 +1,11 @@ +//appearance-settings "use client"; import Image from "next/image"; import { useTheme } from "next-themes"; import { CheckIcon, MinusIcon } from "lucide-react"; import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"; +import { useTranslations } from 'next-intl'; const items = [ { value: "system", label: "System", image: "/ui-system.png" }, @@ -13,11 +15,12 @@ const items = [ export default function AppearanceSettings() { const { theme, setTheme } = useTheme(); + const t = useTranslations('appearance-settings'); return (
- Choose a theme + {t('choose-a-theme')} {items.map((item) => ( diff --git a/src/components/avatar-button.tsx b/src/components/avatar-button.tsx index 647dd9d..b8e4b24 100644 --- a/src/components/avatar-button.tsx +++ b/src/components/avatar-button.tsx @@ -1,3 +1,4 @@ +//avatar-button import { BadgeCheck, Bell, @@ -21,6 +22,7 @@ import { auth, signOut } from "@/lib/auth"; import { redirect } from "next/navigation"; import { Skeleton } from "@/components/ui/skeleton"; import { SettingsButton } from "@/components/settings-button"; +import { useTranslations } from 'next-intl'; const UserAvatar = ({ image, name }: { image: string; name: string }) => ( @@ -45,6 +47,7 @@ export async function AvatarButton() { const image = session?.user?.image ?? "https://github.com/shadcn.png"; const name = session?.user?.name ?? "unknown"; const email = session?.user?.email ?? "unknwon@example.com"; + const t = useTranslations('avatar-button'); return ( @@ -61,7 +64,7 @@ export async function AvatarButton() { - Log In + {t('log-in')} ) : ( @@ -79,7 +82,7 @@ export async function AvatarButton() { - Account + {t('account')} @@ -93,7 +96,7 @@ export async function AvatarButton() { - Log out + {t('log-out')} )} diff --git a/src/components/credentials-sign-in-form.tsx b/src/components/credentials-sign-in-form.tsx index 47e6da0..10bcb8c 100644 --- a/src/components/credentials-sign-in-form.tsx +++ b/src/components/credentials-sign-in-form.tsx @@ -19,6 +19,7 @@ import { useState, useTransition } from "react"; import { zodResolver } from "@hookform/resolvers/zod"; import { signInWithCredentials } from "@/actions/auth"; import { EyeIcon, EyeOffIcon, MailIcon } from "lucide-react"; +import { useTranslations } from 'next-intl'; export type CredentialsSignInFormValues = z.infer; @@ -52,6 +53,8 @@ export function CredentialsSignInForm() { }); }; + const t = useTranslations(''); + return (
@@ -60,7 +63,7 @@ export function CredentialsSignInForm() { name="email" render={({ field }) => ( - Email + {t('email')}
@@ -79,7 +82,7 @@ export function CredentialsSignInForm() { name="password" render={({ field }) => ( - Password + {t('password')}
; @@ -57,6 +58,8 @@ export function CredentialsSignUpForm() { }); }; + const t = useTranslations(''); + return ( @@ -65,7 +68,7 @@ export function CredentialsSignUpForm() { name="email" render={({ field }) => ( - Email + {t('email')}
@@ -84,7 +87,7 @@ export function CredentialsSignUpForm() { name="password" render={({ field }) => ( - Password + {t('password')}
{ @@ -16,7 +19,7 @@ export function GithubSignInForm() { fill="currentColor" /> - Continue with GitHub + {t('continue-with-github')} ); diff --git a/src/components/mode-toggle.tsx b/src/components/mode-toggle.tsx index 81474d7..dab7e2d 100644 --- a/src/components/mode-toggle.tsx +++ b/src/components/mode-toggle.tsx @@ -11,9 +11,12 @@ import { DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu" +import { useTranslations } from "next-intl" export function ModeToggle() { const { setTheme } = useTheme() + //appearance-settings + const t = useTranslations('appearance-settings'); return ( @@ -21,18 +24,18 @@ export function ModeToggle() { setTheme("light")}> - Light + {t('light')} setTheme("dark")}> - Dark + {t('dark')} setTheme("system")}> - System + {t('system')} diff --git a/src/components/nav-main.tsx b/src/components/nav-main.tsx index 7706335..eb09fe8 100644 --- a/src/components/nav-main.tsx +++ b/src/components/nav-main.tsx @@ -16,7 +16,9 @@ import { CollapsibleTrigger, } from "@/components/ui/collapsible"; import { ChevronRight, type LucideIcon } from "lucide-react"; +import { useTranslations } from "next-intl"; +const t = useTranslations('nav'); export interface NavMainProps { items: { title: string; @@ -33,7 +35,7 @@ export interface NavMainProps { export function NavMain({ items }: NavMainProps) { return ( - Platform + {t('platform')} {items.map((item) => !item.items ? ( diff --git a/src/components/nav-projects.tsx b/src/components/nav-projects.tsx index f50b20d..7e8830f 100644 --- a/src/components/nav-projects.tsx +++ b/src/components/nav-projects.tsx @@ -24,6 +24,10 @@ import { SidebarMenuItem, useSidebar, } from "@/components/ui/sidebar" +import { useTranslations } from "next-intl"; + + +const t = useTranslations('nav'); export function NavProjects({ projects, @@ -38,7 +42,7 @@ export function NavProjects({ return ( - Projects + {t('projects')} {projects.map((item) => ( @@ -52,7 +56,7 @@ export function NavProjects({ - More + {t('more')} - View Project + {t('view-project')} - Share Project + {t('share-project')} - Delete Project + {t('delete-project')} @@ -80,7 +84,7 @@ export function NavProjects({ - More + {t('more')} diff --git a/src/components/nav-user.tsx b/src/components/nav-user.tsx index 66190a5..e7e2d00 100644 --- a/src/components/nav-user.tsx +++ b/src/components/nav-user.tsx @@ -24,6 +24,9 @@ import { DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; +import { useTranslations } from "next-intl"; + +const t = useTranslations(''); export interface NavUserProps { user: { @@ -80,28 +83,28 @@ export function NavUser({ - Upgrade to Pro + {t('nav.upgrade-to-pro')} - Account + {t('avatar-button.account')} - Billing + {t('nav.billing')} - Notifications + {t('nav.notifications')} - Log out + {t('avatar-button.log-out')} diff --git a/src/components/navbar.tsx b/src/components/navbar.tsx index 05314c9..a9bd805 100644 --- a/src/components/navbar.tsx +++ b/src/components/navbar.tsx @@ -11,10 +11,12 @@ import { } from "@/components/ui/breadcrumb"; import { Home } from "lucide-react"; import { usePathname } from "next/navigation"; +import { useTranslations } from "next-intl"; export const Navbar = () => { const pathname = usePathname(); const pathSegments = pathname.split("/").filter(Boolean); // Filter out empty strings + const t = useTranslations('nav'); return ( @@ -24,7 +26,7 @@ export const Navbar = () => { ) : ( @@ -33,7 +35,7 @@ export const Navbar = () => { diff --git a/src/components/run-code.tsx b/src/components/run-code.tsx index 7847fcd..c0e446c 100644 --- a/src/components/run-code.tsx +++ b/src/components/run-code.tsx @@ -13,6 +13,9 @@ import { Button } from "@/components/ui/button"; import { useProblem } from "@/hooks/use-problem"; import { LoaderCircleIcon, PlayIcon } from "lucide-react"; import { showStatusToast } from "@/hooks/show-status-toast"; +import { useTranslations } from "next-intl"; + +const t = useTranslations('run-code'); interface RunCodeProps { className?: string; @@ -66,10 +69,10 @@ export function RunCode({ aria-hidden="true" /> )} - {isLoading ? "Running..." : "Run"} + {isLoading ? t('running') : t('run')} - Run Code + {t('run-code')} ); diff --git a/src/components/settings-button.tsx b/src/components/settings-button.tsx index 2d33383..f6b87a1 100644 --- a/src/components/settings-button.tsx +++ b/src/components/settings-button.tsx @@ -3,14 +3,16 @@ import { Settings } from "lucide-react"; import { useSettingsStore } from "@/stores/useSettingsStore"; import { DropdownMenuItem } from "@/components/ui/dropdown-menu"; +import { useTranslations } from "next-intl"; export function SettingsButton() { const { setDialogOpen } = useSettingsStore(); + const t = useTranslations('settings'); return ( setDialogOpen(true)}> - Settings + {t('settings')} ); } diff --git a/src/components/settings-dialog.tsx b/src/components/settings-dialog.tsx index 425a3df..97dbc17 100644 --- a/src/components/settings-dialog.tsx +++ b/src/components/settings-dialog.tsx @@ -29,13 +29,15 @@ import AppearanceSettings from "./appearance-settings"; import { ScrollArea } from "@/components/ui/scroll-area"; import { useSettingsStore } from "@/stores/useSettingsStore"; import { CodeXml, Globe, Paintbrush, Settings } from "lucide-react"; +import { useTranslations } from "next-intl"; +const t = useTranslations('settings'); const data = { nav: [ - { name: "Appearance", icon: Paintbrush }, - { name: "Language & region", icon: Globe }, - { name: "Code Editor", icon: CodeXml }, - { name: "Advanced", icon: Settings }, + { name: t('appearance'), icon: Paintbrush }, + { name: t('language-and-region'), icon: Globe }, + { name: t('code-editor'), icon: CodeXml }, + { name: t('advanced'), icon: Settings }, ], }; @@ -45,9 +47,9 @@ export function SettingsDialog() { return ( - Settings + {t('settings')} - Customize your settings here. + {t('customize-your-settings-here')} @@ -80,7 +82,7 @@ export function SettingsDialog() { - Settings + {t('settings')} @@ -92,7 +94,7 @@ export function SettingsDialog() {
- {activeSetting === "Appearance" ? ( + {activeSetting === t('appearance') ? ( ) : ( Array.from({ length: 10 }).map((_, i) => ( diff --git a/src/components/sign-up-form.tsx b/src/components/sign-up-form.tsx index 265e3a7..895886a 100644 --- a/src/components/sign-up-form.tsx +++ b/src/components/sign-up-form.tsx @@ -1,26 +1,28 @@ import { GithubSignInForm } from "@/components/github-sign-in-form"; import { CredentialsSignUpForm } from "@/components/credentials-sign-up-form"; +import { useTranslations } from 'next-intl'; export function SignUpForm() { + const t = useTranslations('sign-up-form'); return (
-

Sign up to your account

+

{t('sign-up-to-your-account')}

- Enter your email below to sign up to your account + {t('enter-your-email-below-to-sign-up-to-your-account')}

- Or + {t('or')}
- Already have an account?{" "} + {t('already-have-an-account')}{" "} - Sign in + {t('sign-in')}
diff --git a/src/components/submissions-table.tsx b/src/components/submissions-table.tsx index e48e292..b9827a1 100644 --- a/src/components/submissions-table.tsx +++ b/src/components/submissions-table.tsx @@ -10,7 +10,9 @@ import { Submission } from "@/generated/client"; import { getStatusColorClass } from "@/lib/status"; import { EditorLanguageIcons } from "@/config/editor-language-icons"; import { formatDistanceToNow, isBefore, subDays, format } from "date-fns"; +import { useTranslations } from "next-intl"; +const t = useTranslations('submissions'); interface SubmissionsTableProps { submissions: Submission[] } @@ -24,12 +26,12 @@ export default function SubmissionsTable({ submissions }: SubmissionsTableProps) - Index - Status - Language - Time - Memory - Submitted + t('index') + t('status') + t('language') + t('time') + t('memory') + t('submitted') diff --git a/src/components/team-switcher.tsx b/src/components/team-switcher.tsx index 84d7c34..8a78c22 100644 --- a/src/components/team-switcher.tsx +++ b/src/components/team-switcher.tsx @@ -18,6 +18,9 @@ import { SidebarMenuItem, useSidebar, } from "@/components/ui/sidebar" +import { useTranslations } from "next-intl" + +const t = useTranslations('teams'); export function TeamSwitcher({ teams, @@ -63,7 +66,7 @@ export function TeamSwitcher({ sideOffset={4} > - Teams + t('teams') {teams.map((team, index) => ( -
Add team
+
{t('add-team')}
diff --git a/src/components/testcase-card.tsx b/src/components/testcase-card.tsx index 408ce08..5ab9f87 100644 --- a/src/components/testcase-card.tsx +++ b/src/components/testcase-card.tsx @@ -6,7 +6,9 @@ import { } from "@/components/ui/tabs"; import { TestcaseWithDetails } from "@/types/prisma"; import TestcaseForm from "@/components/testcase-form"; +import { useTranslations } from "next-intl"; +const t = useTranslations('test'); interface TestcaseCardProps { testcases: TestcaseWithDetails; } @@ -21,7 +23,7 @@ export default function TestcaseCard({ testcases }: TestcaseCardProps) { value={`case-${index + 1}`} className="data-[state=active]:bg-muted data-[state=active]:shadow-none" > - Case {index + 1} + {t('case')} {index + 1} ))} diff --git a/src/components/testcase-form.tsx b/src/components/testcase-form.tsx index 659dc56..16b55b7 100644 --- a/src/components/testcase-form.tsx +++ b/src/components/testcase-form.tsx @@ -13,7 +13,9 @@ import { toast } from "sonner"; import { useForm } from "react-hook-form"; import { Input } from "@/components/ui/input"; import { zodResolver } from "@hookform/resolvers/zod"; +import { useTranslations } from "next-intl"; +const t = useTranslations('test'); const formSchema = z.record(z.string().min(1)); interface TestcaseFormInterface { @@ -32,7 +34,7 @@ export default function TestcaseForm(props: TestcaseFormInterface) { toast.success(JSON.stringify(values, null, 2)); } catch (error) { console.error("Form submission error", error); - toast.error("Failed to submit the form. Please try again."); + toast.error(t('failed-to-submit-the-form-please-try-again')); } } @@ -50,7 +52,7 @@ export default function TestcaseForm(props: TestcaseFormInterface) {