Skip to content

Commit 99b961b

Browse files
authored
Merge pull request #130 from scroll-tech/language-selector
Update language picker
2 parents 4113c6d + 4aa7b8d commit 99b961b

28 files changed

+1027
-355
lines changed

astro-i18next.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
export default {
33
defaultLocale: "en",
44
showDefaultLocale: true,
5-
locales: ["en", "zh", "es"],
5+
locales: ["en", "es"],
66
load: ["server", "client"],
77
}

public/locales/en/translation.json

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,12 @@
4848
}
4949
},
5050
"NewsletterCTA": {
51-
"title": "Stay updated on the latest Scroll news",
52-
"placeholder": "Enter your email address",
53-
"buttonText": "Sign up"
51+
"title": "Stay up-to-date on the latest Scroll Developer news",
52+
"text": "Roadmap updates, virtual and live events, ecosystem opportunities and more",
53+
"placeholder": "your email address here",
54+
"thankYouForSubscribing": "Thank you for subscribing!",
55+
"correctEmail": "Please use a correct email address.",
56+
"pleaseInsertEmail": "Please insert your email."
5457
}
5558
},
5659
"sidebar": {
@@ -152,6 +155,30 @@
152155
"additionalResources": "Additional Resources"
153156
}
154157
},
158+
"footer": {
159+
"aboutScroll": {
160+
"title": "About Scroll",
161+
"bugBounty": "Bug Bounty",
162+
"joinUs": "Join Us",
163+
"healthStatus": "Health Status",
164+
"privacyPolicy": "Privacy Policy",
165+
"termsAndConditions": "Terms and Conditions"
166+
},
167+
"resources": {
168+
"title": "Resources",
169+
"scrollDocsURL": "https://docs.scroll.io/",
170+
"blog": "Blog",
171+
"documentation": "Documentation",
172+
"pressKit": "Press Kit"
173+
},
174+
"followUs": {
175+
"title": "Follow Us"
176+
}
177+
},
178+
"pageNotFound": {
179+
"title": "Page not found",
180+
"text": "We're sorry, but we couldn't find the page you were looking for."
181+
},
155182
"notTranslated": {
156183
"notTranslated": "This page has not been translated yet."
157184
}

public/locales/es/translation.json

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,12 @@
4848
}
4949
},
5050
"NewsletterCTA": {
51-
"title": "Stay updated on the latest Scroll news",
52-
"placeholder": "Enter your email address",
53-
"buttonText": "Sign up"
51+
"title": "Mantente actualizado con las más recientes noticias sobre el Desarrollo de Scroll",
52+
"text": "Roadmap, actualizaciones, eventos virtuales y presenciales, oportunidades en el ecosistema y más",
53+
"placeholder": "tu correo electrónico aquí",
54+
"thankYouForSubscribing": "¡Gracias por suscribirte!",
55+
"correctEmail": "Por favor usa un correo electrónico válido.",
56+
"pleaseInsertEmail": "Por favor ingresa tu correo electrónico."
5457
}
5558
},
5659
"sidebar": {
@@ -152,7 +155,32 @@
152155
"additionalResources": "Recursos Adicionales"
153156
}
154157
},
158+
"footer": {
159+
"aboutScroll": {
160+
"title": "Acerca de Scroll",
161+
"bugBounty": "Cazarecompensas de bugs",
162+
"joinUs": "Únete a nosotros",
163+
"healthStatus": "Estado de servicios",
164+
"privacyPolicy": "Políticas de privacidad",
165+
"termsAndConditions": "Terminos y condiciones"
166+
},
167+
"resources": {
168+
"title": "Recursos",
169+
"scrollDocsURL": "https://docs.scroll.io/es",
170+
"blog": "Blog",
171+
"documentation": "Documentación",
172+
"pressKit": "Kit de Prensa"
173+
},
174+
"followUs": {
175+
"title": "Síguenos"
176+
}
177+
},
178+
"pageNotFound": {
179+
"title": "Página no encontrada",
180+
"text": "Lo sentimos, pero no pudimos encontrar la página que buscas."
181+
},
155182
"notTranslated": {
156183
"notTranslated": "Esta página no ha sido traducida aún."
157-
}
184+
},
185+
"This email cannot be added to this list. Please enter a different email address.": "Este correo electrónico no puede ser añadido a la lista. Por favor ingresa uno diferente."
158186
}

src/components/Footer/Footer.astro

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
import Subscribe from "./Subscribe/Subscribe.tsx"
3+
import PureFooter from "./PureFooter/PureFooter.tsx"
4+
import i18next from "i18next"
5+
---
6+
7+
<div>
8+
<Subscribe client:idle lang={i18next.language} />
9+
<PureFooter />
10+
</div>

src/components/Footer/Footer.tsx

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/components/Footer/PureFooter/PureFooter.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { useState, useEffect } from "preact/hooks"
22
import { aboutList, mediaList, resourceList } from "../helper.tsx"
33
import styles from "./PureFooter.module.css"
4+
import { t } from "i18next"
45

56
const Footer = () => {
67
return (
@@ -9,28 +10,28 @@ const Footer = () => {
910
<img src="/scroll-white.svg" style={{ width: "80px" }} />
1011
</a>
1112
<div className={styles.about}>
12-
<p className={styles.title}>About Scroll</p>
13+
<p className={styles.title}>{ t("footer.aboutScroll.title") }</p>
1314
<ul>
1415
{aboutList.map((item) => (
1516
<li key={item.name} className={styles.content}>
16-
<a href={item.href}>{item.name}</a>
17+
<a href={item.href}>{t(item.name)}</a>
1718
</li>
1819
))}
1920
</ul>
2021
</div>
2122
<div className={styles.resource}>
22-
<p className={styles.title}>Resources</p>
23+
<p className={styles.title}>{ t("footer.resources.title") }</p>
2324
<ul>
2425
{resourceList.map((item) => (
2526
<li key={item.name} className={styles.content}>
26-
<a href={item.href}>{item.name}</a>
27+
<a href={item.href}>{t(item.name)}</a>
2728
</li>
2829
))}
2930
</ul>
3031
</div>
3132

3233
<div className={styles.follow}>
33-
<p className={styles.title}>Follow Us</p>
34+
<p className={styles.title}>{ t("footer.followUs.title") }</p>
3435
<div>
3536
{mediaList.map((item) => (
3637
<a external href={item.href} key={item.name} target="_blank">
@@ -39,8 +40,6 @@ const Footer = () => {
3940
))}
4041
</div>
4142
</div>
42-
43-
<p className={styles.version}>© Version 1.0.0 Scroll Ltd 2023</p>
4443
</div>
4544
)
4645
}

src/components/Footer/Subscribe/EmailInput.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from "react"
22
import styles from "./EmailInput.module.css"
33
import ArrowSvg from "~/assets/svgs/footer/arrow-right.svg?react"
44
import { clsx } from "~/lib"
5+
import { t } from "i18next"
56

67
const EmailInput = (props) => {
78
const { end, onClick, onEnter, ...restProps } = props
@@ -23,7 +24,7 @@ const EmailInput = (props) => {
2324
<button className={clsx(styles.iconButton, "dark:text-black")} onClick={onClick} disabled={end}>
2425
<ArrowSvg></ArrowSvg>
2526
</button>
26-
<div className={clsx(styles.success, "dark:text-black", "dark:bg-white")}>Thank you for subscribing!</div>
27+
<div className={clsx(styles.success, "dark:text-black", "dark:bg-white")}>{ t("landing.NewsletterCTA.thankYouForSubscribing") }</div>
2728
</div>
2829
<input
2930
placeholder="your email address here"

src/components/Footer/Subscribe/Subscribe.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { useState, useEffect } from "preact/hooks"
33
import MailchimpSubscribe from "react-mailchimp-subscribe"
44
import SubscribeSvg from "~/assets/svgs/footer/subscribe.svg?react"
55
import { clsx } from "~/lib"
6+
import i18next, { changeLanguage, t } from "i18next"
67

78
import EmailInput from "./EmailInput.tsx"
89
import styles from "./Subscribe.module.css"
@@ -14,21 +15,23 @@ const isValidEmail = (email: string): boolean => {
1415
return emailRegex.test(email)
1516
}
1617

17-
export default function Subscribe() {
18+
export default function Subscribe(props) {
1819
const [email, setEmail] = useState("")
1920
const [customMessage, setCustomMessage] = useState("")
2021
const [emailValid, setEmailValid] = useState(false)
2122

23+
i18next.changeLanguage(props.lang)
24+
2225
useEffect(() => {
2326
setCustomMessage("")
2427
setEmailValid(isValidEmail(email))
2528
}, [email])
2629

2730
const handleSubmit = (subscribe) => {
2831
if (!email) {
29-
setCustomMessage("Please insert your email.")
32+
setCustomMessage(t("landing.NewsletterCTA.pleaseInsertEmail"))
3033
} else if (!emailValid) {
31-
setCustomMessage("Please use a correct email address.")
34+
setCustomMessage(t("landing.NewsletterCTA.correctEmail"))
3235
} else {
3336
subscribe({ EMAIL: email })
3437
setEmail("")
@@ -47,9 +50,9 @@ export default function Subscribe() {
4750
</span>
4851

4952
<div className={styles.copyBox}>
50-
<div className={styles.subscribeTitle}>Stay up-to-date on the latest Scroll Developer news</div>
53+
<div className={styles.subscribeTitle}>{ t("landing.NewsletterCTA.title") }</div>
5154
<div className={styles.subscribeText}>
52-
Roadmap updates, virtual and live events, ecosystem opportunities and more
55+
{ t("landing.NewsletterCTA.text") }
5356
</div>
5457
</div>
5558
<MailchimpSubscribe
@@ -62,11 +65,11 @@ export default function Subscribe() {
6265
onChange={handleChangeEmail}
6366
onClick={() => handleSubmit(subscribe)}
6467
onEnter={() => handleSubmit(subscribe)}
65-
placeholder="your email address here"
68+
placeholder= { t("landing.NewsletterCTA.placeholder") }
6669
end={status === "success"}
6770
/>
6871
{customMessage && <div className={styles.errorMessage}>{customMessage}</div>}
69-
{status === "error" && <div className={styles.errorMessage}>{message}</div>}
72+
{status === "error" && <div className={styles.errorMessage}>{t(message)}</div>}
7073
</div>
7174
)}
7275
/>

src/components/Footer/helper.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,38 +23,38 @@ const TwitterIcon: React.FC<React.SVGProps<SVGSVGElement>> = (props) => (
2323

2424
export const aboutList = [
2525
{
26-
name: "Bug Bounty",
26+
name: "footer.aboutScroll.bugBounty",
2727
href: "https://immunefi.com/bounty/scroll/",
2828
},
2929
{
30-
name: "Join Us",
30+
name: "footer.aboutScroll.joinUs",
3131
href: "https://jobs.lever.co/ScrollFoundation",
3232
},
3333
{
34-
name: "Health Status",
34+
name: "footer.aboutScroll.healthStatus",
3535
href: "https://status.scroll.io/",
3636
},
3737
{
38-
name: "Privacy Policy",
38+
name: "footer.aboutScroll.privacyPolicy",
3939
href: "https://scroll.io/privacy-policy",
4040
},
4141
{
42-
name: "Terms and Conditions",
42+
name: "footer.aboutScroll.termsAndConditions",
4343
href: "https://scroll.io/terms-and-conditions",
4444
},
4545
]
4646

4747
export const resourceList = [
4848
{
49-
name: "Blog",
49+
name: "footer.resources.blog",
5050
href: "https://scroll.io/blog",
5151
},
5252
{
53-
name: "Documentation",
53+
name: "footer.resources.documentation",
5454
href: "https://docs.scroll.io/",
5555
},
5656
{
57-
name: "Press Kit",
57+
name: "footer.resources.pressKit",
5858
href: "https://scrollzkp.notion.site/Scroll-Rebrand-Assets-5bb83465f56f40989c4f772b39ed3a06",
5959
},
6060
]

src/components/Header/Header.astro

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,10 @@ const section = frontmatter?.section ?? ""
7676
</div>
7777
)
7878
}
79-
<ThemeModeToggle client:only="preact" dark={dark} />
80-
<LanguageSelector class="language-selector" />
79+
<span class="theme-item">
80+
<ThemeModeToggle client:only="preact" dark={dark} />
81+
</span>
82+
<LanguageSelector class="language-selector" dark={dark} />
8183
<a href="https://github.com/scroll-tech/scroll-documentation" class="github-url" target="_blank" rel="nofollow">
8284
<span
8385
class={clsx(
@@ -113,6 +115,7 @@ const section = frontmatter?.section ?? ""
113115
padding-top: 7px;
114116
@apply text-black dark:text-white;
115117
color: var(--textColor);
118+
white-space: nowrap;
116119
}
117120
.nav-link:hover {
118121
@apply text-link;
@@ -243,4 +246,33 @@ const section = frontmatter?.section ?? ""
243246
grid-template-columns: minmax(230px, 1fr) 5fr;
244247
}
245248
}
249+
250+
/* Very Hacky way to make Spanish not break at narrow screens */
251+
252+
@media (max-width: 72em) and (min-width: 50em) {
253+
.queryResults {
254+
grid-template-columns: 1fr !important;
255+
}
256+
257+
.search-item,
258+
.github-url {
259+
display: none;
260+
}
261+
}
262+
263+
@media (max-width: 62em) and (min-width: 50em) {
264+
.theme-item {
265+
display: none;
266+
}
267+
}
268+
269+
@media (max-width: 58em) and (min-width: 50em) {
270+
.tools {
271+
transform: scale(0.85);
272+
}
273+
274+
.navbar {
275+
gap: 25px;
276+
}
277+
}
246278
</style>

0 commit comments

Comments
 (0)