Skip to content

Commit a46e5b1

Browse files
authored
Merge pull request #8 from tomihq/feature/translate-to-spanish
Translate to spanish
2 parents 8458004 + a005df2 commit a46e5b1

File tree

122 files changed

+8128
-19799
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+8128
-19799
lines changed
File renamed without changes.
File renamed without changes.

app/[locale]/layout.tsx

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import "../globals.css";
2+
3+
import { disableUser, saveProfileData } from "@/services/user";
4+
5+
import { ClientProviders } from "@/components/provider/client-providers";
6+
import Script from "next/script";
7+
import WithSessionLayout from "@/components/provider/with-session-layout";
8+
import { cookies } from "next/headers";
9+
import { getNotificationsByUserId } from "@/services/notifications";
10+
import { logout } from "@/services/auth";
11+
12+
type Locale = "en" | "es";
13+
14+
export default async function LocaleLayout({
15+
children,
16+
}: {
17+
children: React.ReactNode;
18+
}) {
19+
const cookieStore = await cookies();
20+
const localeCookie = cookieStore.get("NEXT_LOCALE")?.value as
21+
| Locale
22+
| undefined;
23+
const locale: Locale = localeCookie === "es" ? "es" : "en";
24+
25+
const messages = (await import(`@/messages/${locale}.json`)).default;
26+
27+
return (
28+
<>
29+
<Script
30+
id='clarity-script'
31+
strategy='afterInteractive'
32+
dangerouslySetInnerHTML={{
33+
__html: `
34+
(function(c,l,a,r,i,t,y){
35+
c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
36+
t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
37+
y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
38+
})(window, document, "clarity", "script", "sk0lq3aio2");
39+
`,
40+
}}
41+
/>
42+
<WithSessionLayout>
43+
<ClientProviders
44+
disableUser={disableUser}
45+
saveProfileData={saveProfileData}
46+
getNotificationsByUserId={getNotificationsByUserId}
47+
onLogout={logout}
48+
locale={locale}
49+
messages={messages}
50+
>
51+
{children}
52+
</ClientProviders>
53+
</WithSessionLayout>
54+
</>
55+
);
56+
}
Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
import { useState } from 'react'
44
import { motion } from 'framer-motion'
5-
import { useRouter } from 'next/navigation'
6-
import Link from 'next/link'
5+
import { useRouter } from '@/i18n/routing'
76
import { Formik, Form, Field } from 'formik'
87
import * as Yup from 'yup'
98
import { Button } from '@/components/ui/button'
@@ -14,26 +13,28 @@ import ThirdPartyLogin from '@/components/auth/third-party-login'
1413
import { useTheme } from 'next-themes'
1514
import { cn } from '@/lib/utils'
1615
import { BLACK_BACKGROUND, BLACK_BACKGROUND_CONTAINERS } from '@/lib/colors'
17-
import { ModeToggle } from '../../components/theme-switcher';
18-
19-
const LoginSchema = Yup.object().shape({
20-
email: Yup.string().email('Invalid email').required('Email is required'),
21-
password: Yup.string().required('Password is required'),
22-
})
16+
import { ModeToggle } from '@/components/theme-switcher';
17+
import { useTranslations } from 'next-intl';
2318

2419
const taskEmojis = ['✅', '📝', '🏋️‍♀️', '📚', '🧘‍♀️', '💧', '🥗', '😴']
2520

2621

2722
const LoginForm = () => {
23+
const t = useTranslations('auth.login');
2824
const [isLoading, setIsLoading] = useState(false)
2925
const router = useRouter()
3026
const { theme } = useTheme()
3127

28+
const LoginSchema = Yup.object().shape({
29+
email: Yup.string().email(t('validation.emailInvalid')).required(t('validation.emailRequired')),
30+
password: Yup.string().required(t('validation.passwordRequired')),
31+
})
32+
3233
const handleLogin = async (values, { setSubmitting, setErrors }) => {
3334
setIsLoading(true)
3435

3536
if (values.email !== 'test@example.com' || values.password !== 'password123') {
36-
setErrors({ email: 'Invalid email or password' })
37+
setErrors({ email: t('validation.invalidCredentials') })
3738
} else {
3839
localStorage.setItem('userName', values.email.split('@')[0])
3940
router.push('/onboarding')
@@ -51,20 +52,20 @@ const LoginForm = () => {
5152
</div>
5253
<div className="mx-auto w-full max-w-sm lg:w-[450px] ">
5354
<div className="text-center">
54-
<motion.div
55+
<motion.div
5556
className="text-4xl mb-2"
5657
initial={{ scale: 0 }}
5758
animate={{ scale: 1 }}
5859
transition={{ type: "spring", stiffness: 260, damping: 20 }}
5960
>
6061
🚀
6162
</motion.div>
62-
<h2 className="mt-6 text-3xl font-extrabold text-gray-900 dark:text-white">Welcome back</h2>
63+
<h2 className="mt-6 text-3xl font-extrabold text-gray-900 dark:text-white">{t('title')}</h2>
6364
<p className="mt-2 text-sm text-gray-600 dark:text-gray-300">
64-
Sign in to continue your journey
65+
{t('subtitle')}
6566
</p>
6667
</div>
67-
68+
6869
<div className="mt-8">
6970
<Formik
7071
initialValues={{ email: '', password: '' }}
@@ -75,7 +76,7 @@ const LoginForm = () => {
7576
<Form className="space-y-6">
7677
<div>
7778
<Label htmlFor="email" className="block text-sm font-medium text-gray-700 dark:text-white">
78-
Email address
79+
{t('email')}
7980
</Label>
8081
<div className="mt-1">
8182
<Field
@@ -92,10 +93,10 @@ const LoginForm = () => {
9293
)}
9394
</div>
9495
</div>
95-
96+
9697
<div>
9798
<Label htmlFor="password" className="block text-sm font-medium text-gray-700 dark:text-white">
98-
Password
99+
{t('password')}
99100
</Label>
100101
<div className="mt-1">
101102
<Field
@@ -112,7 +113,7 @@ const LoginForm = () => {
112113
)}
113114
</div>
114115
</div>
115-
116+
116117
<div>
117118
<Button
118119
type="submit"
@@ -123,7 +124,7 @@ const LoginForm = () => {
123124
<Loader2 className="w-5 h-5 animate-spin" />
124125
) : (
125126
<>
126-
Sign in
127+
{t('signInButton')}
127128
<ArrowRight className="ml-2 -mr-1 w-5 h-5" />
128129
</>
129130
)}
@@ -132,23 +133,23 @@ const LoginForm = () => {
132133
</Form>
133134
)}
134135
</Formik>
135-
136+
136137
<div className="mt-6">
137138
<div className="relative">
138139
<div className="absolute inset-0 flex items-center">
139140
<div className="w-full border-t border-gray-300 dark:border-slate-700" />
140141
</div>
141142
<div className="relative flex justify-center text-sm">
142-
<span className="px-2 bg-gray-50 text-gray-500 dark:text-white dark:bg-slate-900">Or continue with</span>
143+
<span className="px-2 bg-gray-50 text-gray-500 dark:text-white dark:bg-slate-900">{t('orContinueWith')}</span>
143144
</div>
144145
</div>
145-
146+
146147
<div className="mt-6">
147148
<ThirdPartyLogin/>
148149
</div>
149150
</div>
150-
151-
151+
152+
152153
</div>
153154
</div>
154155
</div>
@@ -173,4 +174,4 @@ const LoginForm = () => {
173174
)
174175
}
175176

176-
export default LoginForm
177+
export default LoginForm

app/[locale]/login/page.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { config } from '@/config/environment'
2+
import LoginForm from './login-form'
3+
import { routing } from '@/i18n/routing'
4+
5+
export const dynamic = "force-static"
6+
7+
export function generateStaticParams() {
8+
return routing.locales.map((locale) => ({ locale }));
9+
}
10+
11+
export const metadata ={
12+
title: `Login | ${config.brandName}`
13+
}
14+
15+
export default async function LoginPage({
16+
params,
17+
}: {
18+
params: Promise<{ locale: string }>;
19+
}) {
20+
return (
21+
<LoginForm/>
22+
)
23+
}
24+

0 commit comments

Comments
 (0)