Skip to content

Commit fd9b88b

Browse files
authored
Merge pull request #47 from okisdev/i18n-Japanese
2 parents d926f94 + b126297 commit fd9b88b

30 files changed

+671
-199
lines changed

app/[locale]/layout.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import 'tippy.js/dist/tippy.css';
44

55
import { NextIntlClientProvider } from 'next-intl';
66

7+
import { HotToaster } from '@/components/client/toaster';
8+
import { ClientCommand } from '@/components/client/command';
9+
710
import NotFound from '@/app/not-found';
811

912
export default async function LocaleLayout({ children, params: { locale } }: { children: React.ReactNode; params: { locale: string } }) {
@@ -17,6 +20,9 @@ export default async function LocaleLayout({ children, params: { locale } }: { c
1720

1821
return (
1922
<NextIntlClientProvider locale={locale} messages={messages}>
23+
<HotToaster />
24+
<ClientCommand />
25+
2026
{children}
2127
</NextIntlClientProvider>
2228
);
File renamed without changes.

app/layout.tsx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,12 @@ import '@/styles/globals.css';
22
import '@/styles/markdown.css';
33
import 'tippy.js/dist/tippy.css';
44

5-
import { rubik } from '@/app/[locale]/fonts';
5+
import { rubik } from '@/app/fonts';
66

77
import { Providers } from '@/app/providers';
88

99
import { Analytics } from '@vercel/analytics/react';
1010

11-
import { HotToaster } from '@/components/client/toaster';
12-
import { ClientCommand } from '@/components/client/command';
13-
1411
import { siteConfig } from '@/config/site.config';
1512

1613
export default async function RootLayout({ children, params: { locale } }: { children: React.ReactNode; params: { locale: string } }) {
@@ -59,12 +56,7 @@ export default async function RootLayout({ children, params: { locale } }: { chi
5956
</head>
6057

6158
<body className='min-h-screen bg-slate-50 dark:bg-[#323233] dark:text-[#eee]'>
62-
<Providers>
63-
<HotToaster />
64-
<ClientCommand />
65-
66-
{children}
67-
</Providers>
59+
<Providers>{children}</Providers>
6860
<Analytics />
6961
</body>
7062
</html>

components/auth/form.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ const AuthForm = ({ login }: { login: boolean }) => {
2323

2424
const handleEmailSubmit = async () => {
2525
if (!email) {
26-
return toast.error('Email is required');
26+
return toast.error(t('Email is required'));
2727
}
2828

2929
if (!email.includes('@')) {
30-
return toast.error('Invalid email');
30+
return toast.error(t('Invalid email'));
3131
}
3232

3333
const emailSignIn = await signIn('email', {
@@ -37,10 +37,10 @@ const AuthForm = ({ login }: { login: boolean }) => {
3737
});
3838

3939
if (emailSignIn?.error) {
40-
return toast.error('Failed to send email');
40+
return toast.error(t('Failed to send email'));
4141
}
4242

43-
toast.success('Email sent. Please check your inbox.');
43+
toast.success(t('Email sent, please check your inbox'));
4444
};
4545

4646
return (

components/client/command.tsx

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@ import { Settings, User } from 'lucide-react';
99
import { FiCode, FiFile, FiMessageCircle } from 'react-icons/fi';
1010

1111
import { CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut } from '@/components/ui/command';
12+
import { useTranslations } from 'next-intl';
1213

1314
export const ClientCommand = () => {
1415
const router = useRouter();
1516

17+
const t = useTranslations('component');
18+
1619
const [open, setOpen] = React.useState(false);
1720

1821
React.useEffect(() => {
@@ -28,10 +31,10 @@ export const ClientCommand = () => {
2831

2932
return (
3033
<CommandDialog open={open} onOpenChange={setOpen}>
31-
<CommandInput placeholder='Type a command or search...' />
34+
<CommandInput placeholder={t('Type a command to search')} />
3235
<CommandList>
33-
<CommandEmpty>No results found.</CommandEmpty>
34-
<CommandGroup heading='Conversation'>
36+
<CommandEmpty>{t('No command found')}</CommandEmpty>
37+
<CommandGroup heading={t('Conversation')}>
3538
<CommandItem>
3639
<button
3740
onClick={() => {
@@ -41,7 +44,7 @@ export const ClientCommand = () => {
4144
className='flex items-center'
4245
>
4346
<FiMessageCircle className='mr-2 h-4 w-4' />
44-
<span>New Chat</span>
47+
<span>{t('New Chat')}</span>
4548
</button>
4649
</CommandItem>
4750
<CommandItem>
@@ -53,7 +56,7 @@ export const ClientCommand = () => {
5356
className='flex items-center'
5457
>
5558
<FiCode className='mr-2 h-4 w-4' />
56-
<span>New Code</span>
59+
<span>{t('New Code')}</span>
5760
</button>
5861
</CommandItem>
5962
<CommandItem>
@@ -65,12 +68,12 @@ export const ClientCommand = () => {
6568
className='flex items-center'
6669
>
6770
<FiFile className='mr-2 h-4 w-4' />
68-
<span>New File</span>
71+
<span>{t('New File')}</span>
6972
</button>
7073
</CommandItem>
7174
</CommandGroup>
7275
<CommandSeparator />
73-
<CommandGroup heading='Profile'>
76+
<CommandGroup heading={t('Profile')}>
7477
<CommandItem>
7578
<button
7679
onClick={() => {
@@ -80,7 +83,7 @@ export const ClientCommand = () => {
8083
className='flex items-center'
8184
>
8285
<User className='mr-2 h-4 w-4' />
83-
<span>Info</span>
86+
<span>{t('Info')}</span>
8487
</button>
8588
</CommandItem>
8689
<CommandItem>
@@ -92,7 +95,7 @@ export const ClientCommand = () => {
9295
className='flex items-center'
9396
>
9497
<User className='mr-2 h-4 w-4' />
95-
<span>Share</span>
98+
<span>{t('Share')}</span>
9699
</button>
97100
</CommandItem>
98101
<CommandItem>
@@ -104,12 +107,12 @@ export const ClientCommand = () => {
104107
className='flex items-center'
105108
>
106109
<Settings className='mr-2 h-4 w-4' />
107-
<span>Settings</span>
110+
<span>{t('Settings')}</span>
108111
</button>
109112
</CommandItem>
110113
</CommandGroup>
111114
<CommandSeparator />
112-
<CommandGroup heading='Team'>
115+
<CommandGroup heading={t('Team')}>
113116
<CommandItem>
114117
<button
115118
onClick={() => {
@@ -119,7 +122,7 @@ export const ClientCommand = () => {
119122
className='flex items-center'
120123
>
121124
<User className='mr-2 h-4 w-4' />
122-
<span>Overview</span>
125+
<span>{t('Overview')}</span>
123126
</button>
124127
</CommandItem>
125128
</CommandGroup>

components/dashboard/profile-info-form.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import { Separator } from '@/components/ui/separator';
1818

1919
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from '@/components/ui/dialog';
2020

21-
import { siteConfig } from '@/config/site.config';
2221
import { signOut } from 'next-auth/react';
2322

2423
const ProfileInfoForm = ({ user }: any) => {
@@ -51,12 +50,12 @@ const ProfileInfoForm = ({ user }: any) => {
5150

5251
if (!response?.ok) {
5352
setIsLoading(false);
54-
toast.error('Something went wrong.');
53+
toast.error(t('Error: Something went wrong'));
5554
return;
5655
}
5756

5857
setIsLoading(false);
59-
toast.success('Profile updated.');
58+
toast.success(t('Profile updated'));
6059
};
6160

6261
const onDelete = async () => {
@@ -68,11 +67,11 @@ const ProfileInfoForm = ({ user }: any) => {
6867
});
6968

7069
if (!response?.ok) {
71-
toast.error('Something went wrong.');
70+
toast.error(t('Error: Something went wrong'));
7271
return;
7372
}
7473

75-
toast.success('Account deleted.');
74+
toast.success(t('Account deleted'));
7675

7776
await signOut();
7877

@@ -112,7 +111,7 @@ const ProfileInfoForm = ({ user }: any) => {
112111
</p>
113112
<Dialog open={isDialogOpen} onOpenChange={setIsDialogOpen}>
114113
<DialogTrigger asChild>
115-
<button className='text-sm text-red-500'>Delete Account</button>
114+
<button className='text-sm text-red-500'>{t('Delete Account')}</button>
116115
</DialogTrigger>
117116
<DialogContent>
118117
<DialogHeader>

components/dashboard/profile-settings-form.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const ProfileSettingsForm = ({ user }: { user: User }) => {
4040

4141
if (!response?.ok) {
4242
setIsLoading(false);
43-
toast.error('Something went wrong.');
43+
toast.error(t('Error: Something went wrong'));
4444
return;
4545
}
4646

components/dashboard/record/button.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,19 @@ const RecordButton = ({ records }: { records: Record[] }) => {
3737
};
3838

3939
const handleDelete = async () => {
40-
const confirm = window.confirm('Are you sure you want to delete all records?');
40+
const confirm = window.confirm(t('Are you sure you want to delete all records?'));
4141

4242
if (confirm) {
4343
const response = await fetch('/api/record/delete', {
4444
method: 'DELETE',
4545
});
4646

4747
if (!response.ok) {
48-
toast.error('Something went wrong. Please try again later.');
48+
toast.error(t('Something went wrong, please try again later'));
4949
return;
5050
}
5151

52-
toast.success('Successfully deleted all records.');
52+
toast.success(t('Successfully deleted all records'));
5353

5454
router.refresh();
5555
}

components/dashboard/record/card.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,29 +41,29 @@ const RecordCard = ({ record }: { record: Record }) => {
4141
if (!response.ok) {
4242
if (response.status === 409) {
4343
navigator.clipboard.writeText(window.location.host + `/s/${record.id}`);
44-
toast.error(`Share already exists: ${record.id}`);
44+
toast.error(`${t('Updated previous share:')} ${record.id}`);
4545
return;
4646
}
47-
toast.error('Error: Something went wrong');
47+
toast.error(t('Error: Something went wrong'));
4848
return;
4949
}
5050

5151
const data = await response.json();
5252

5353
if (!data.success) {
54-
toast.error('Error: Something went wrong');
54+
toast.error(t('Error: Something went wrong'));
5555
return;
5656
}
5757

5858
navigator.clipboard.writeText(window.location.host + `/s/${record.id}`);
59-
toast.success(`Share: ${record.id} link copied`);
59+
toast.success(`${t('Copied share link:')} ${record.id}`);
6060
};
6161

6262
const onCopy = () => {
6363
const url = `${window.location.origin}/s/${record.id}`;
6464

6565
navigator.clipboard.writeText(url);
66-
toast.success(`Share: ${record.id} link copied`);
66+
toast.success(`${t('Copied share link:')} ${record.id}`);
6767
};
6868

6969
const onDelete = async () => {
@@ -72,18 +72,18 @@ const RecordCard = ({ record }: { record: Record }) => {
7272
});
7373

7474
if (!response.ok) {
75-
toast.error('Error: Something went wrong');
75+
toast.error(t('Error: Something went wrong'));
7676
return;
7777
}
7878

7979
const data = await response.json();
8080

8181
if (!data.success) {
82-
toast.error('Error: Something went wrong');
82+
toast.error(t('Error: Something went wrong'));
8383
return;
8484
}
8585

86-
toast.success(`Record: ${record.id} deleted`);
86+
toast.success(`${t('Deleted record:')} ${record.id}`);
8787

8888
router.refresh();
8989
};

components/dashboard/team/card.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,18 @@ const TeamCard = ({ team }: { team: Team & { isAuthor: boolean } }) => {
4444
});
4545

4646
if (!response.ok) {
47-
toast.error('Failed to delete team');
47+
toast.error(t('Failed to delete team'));
4848
return;
4949
}
5050

5151
const data = await response.json();
5252

5353
if (!data.success) {
54-
toast.error('Failed to delete team');
54+
toast.error(t('Failed to delete team'));
5555
return;
5656
}
5757

58-
toast.success('Team deleted');
58+
toast.success(t('Team deleted'));
5959

6060
setIsDeleteDialogOpen(false);
6161

@@ -74,14 +74,14 @@ const TeamCard = ({ team }: { team: Team & { isAuthor: boolean } }) => {
7474
});
7575

7676
if (!response.ok) {
77-
toast.error('Failed to delete team');
77+
toast.error(t('Failed to quit team'));
7878
return;
7979
}
8080

8181
const data = await response.json();
8282

8383
if (!data.success) {
84-
toast.error('Failed to delete team');
84+
toast.error(t('Failed to quit team'));
8585
return;
8686
}
8787

@@ -107,18 +107,18 @@ const TeamCard = ({ team }: { team: Team & { isAuthor: boolean } }) => {
107107
});
108108

109109
if (!response.ok) {
110-
toast.error('Failed to update team');
110+
toast.error(t('Failed to update team'));
111111
return;
112112
}
113113

114114
const data = await response.json();
115115

116116
if (!data.success) {
117-
toast.error('Failed to update team');
117+
toast.error(t('Failed to update team'));
118118
return;
119119
}
120120

121-
toast.success('Team updated');
121+
toast.success(t('Team updated'));
122122

123123
setIsEditDialogOpen(false);
124124

0 commit comments

Comments
 (0)