Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add localization #131

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 71 additions & 11 deletions components/layout/Menu.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,43 @@
import Link from "next/link"
import { useRouter } from "next/router"
import { useTranslations } from 'next-intl'
import { useState } from 'react'

export default function Menu() {
const router = useRouter();
const router = useRouter()
const t = useTranslations('Menu')
const [isLangDropdownOpen, setIsLangDropdownOpen] = useState(false)

const toggleLangDropdown = () => {
setIsLangDropdownOpen(!isLangDropdownOpen)
}

return (
<>

<ul className="wsmenu-list nav-theme">

<li aria-haspopup="true">
<Link href="#" className="h-link">Learn<span className="wsarrow" /></Link>
<Link href="#" locale={router.locale} className="h-link">{t('learn')}<span className="wsarrow" /></Link>
<ul className="sub-menu">
<li aria-haspopup="true"><Link href="/whitepaper">Whitepaper</Link></li>
<li aria-haspopup="true"><Link href="/#features">Features</Link></li>
<li aria-haspopup="true"><Link href="/faqs">FAQs</Link></li>
<li aria-haspopup="true"><Link href="/whitepaper" locale={router.locale}>{t('whitepaper')}</Link></li>
<li aria-haspopup="true"><Link href="/#features" locale={router.locale}>{t('features')}</Link></li>
<li aria-haspopup="true"><Link href="/faqs" locale={router.locale}>{t('faqs')}</Link></li>
</ul>
</li>

<li className="nl-simple" aria-haspopup="true">
<Link href="https://docs.koinos.io" className="h-link">Documentation</Link>
<Link href="https://docs.koinos.io" locale={router.locale} className="h-link">{t('documentation')}</Link>
</li>

<li className="nl-simple" aria-haspopup="true">
<Link href="/ecosystem" className="h-link">Ecosystem</Link>
<Link href="/ecosystem" locale={router.locale} className="h-link">{t('ecosystem')}</Link>
</li>

<li className="nl-simple" aria-haspopup="true">
<Link href="/#roadmap" className="h-link">Roadmap</Link>
<Link href="/#roadmap" locale={router.locale} className="h-link">{t('roadmap')}</Link>
</li>

<li className="nl-simple" aria-haspopup="true">
<Link href="/team" className="h-link">Team</Link>
<Link href="/team" locale={router.locale} className="h-link">{t('team')}</Link>
</li>

<li className="nl-simple" aria-haspopup="true">
Expand All @@ -42,6 +48,60 @@ export default function Menu() {
</a>
</Link>
</li>

<li aria-haspopup="true" className="nl-simple">
<div className="language-switcher position-relative" style={{paddingTop: '1.2em'}}>
<button
onClick={toggleLangDropdown}
className="bg-transparent border-0 text-inherit"
aria-label="Toggle language"
>
<i className="fa-solid fa-globe text-white"></i>
</button>

{isLangDropdownOpen && (
<div className="lang-dropdown position-absolute shadow-sm rounded py-2" style={{
right: 0,
top: '100%',
minWidth: '100px',
zIndex: 1000
}}>
<Link
href={router.asPath}
locale="en"
className={`d-block px-3 py-1 text-decoration-none text-left ${router.locale === 'en' ? 'active' : ''}`}
onClick={() => setIsLangDropdownOpen(false)}
>
English
</Link>
<Link
href={router.asPath}
locale="es"
className={`d-block px-3 py-1 text-decoration-none text-left ${router.locale === 'es' ? 'active' : ''}`}
onClick={() => setIsLangDropdownOpen(false)}
>
Español
</Link>
<Link
href={router.asPath}
locale="it"
className={`d-block px-3 py-1 text-decoration-none text-left ${router.locale === 'es' ? 'active' : ''}`}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy paste error? locale == 'es' seems wrong.

onClick={() => setIsLangDropdownOpen(false)}
>
Italiano
</Link>
<Link
href={router.asPath}
locale="fa"
className={`d-block px-3 py-1 text-decoration-none text-left ${router.locale === 'es' ? 'active' : ''}`}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy paste error? locale == 'es' seems wrong.

onClick={() => setIsLangDropdownOpen(false)}
>
فارسی
</Link>
</div>
)}
</div>
</li>
</ul>
</>
)
Expand Down
141 changes: 107 additions & 34 deletions components/layout/MobileMenu.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import Link from "next/link";
import { useState } from "react";
import { useRouter } from "next/router"
import { useTranslations } from 'next-intl'

export default function MobileMenu({ handleMobileMenu }) {
const [isActive, setIsActive] = useState({
status: false,
key: "",
});
const router = useRouter()
const t = useTranslations('Menu')
const [isLangDropdownOpen, setIsLangDropdownOpen] = useState(false)

const handleToggle = (key) => {
if (isActive.key === key) {
Expand All @@ -26,6 +32,7 @@ export default function MobileMenu({ handleMobileMenu }) {
className="wsmenu-list nav-theme"
style={{
paddingTop: "22px",
textAlign: "left"
}}
>
{/* DROPDOWN SUB MENU */}
Expand All @@ -38,28 +45,27 @@ export default function MobileMenu({ handleMobileMenu }) {
>
<i className="wsmenu-arrow" />
</span>
<Link href="#" className="h-link">
Learn
<Link href="#" className="h-link text-start" locale={router.locale} style={{ textAlign: "left" }}>
{t('learn')}
<span className="wsarrow" />
</Link>
<ul
className="sub-menu"
style={{ display: `${isActive.key == 1 ? "block" : "none"}` }}
>
<li aria-haspopup="true">
<Link href="/whitepaper" onClick={handleMobileMenu}>
Whitepaper
<Link href="/whitepaper" locale={router.locale} onClick={handleMobileMenu}>
{t('whitepaper')}
</Link>
</li>
<li aria-haspopup="true">
<Link href="/#features" onClick={handleMobileMenu}>
Features
<Link href="/#features" locale={router.locale} onClick={handleMobileMenu}>
{t('features')}
</Link>
</li>
{/*<li aria-haspopup="true"><Link href="/framework">Framework</Link></li>*/}
<li aria-haspopup="true">
<Link href="/faqs" onClick={handleMobileMenu}>
FAQs
<Link href="/faqs" locale={router.locale} onClick={handleMobileMenu}>
{t('faqs')}
</Link>
</li>
</ul>
Expand All @@ -69,58 +75,125 @@ export default function MobileMenu({ handleMobileMenu }) {
<Link
href="https://docs.koinos.io"
onClick={handleMobileMenu}
className="h-link"
className="h-link text-start"
locale={router.locale}
style={{ textAlign: "left" }}
>
Documentation
{t('documentation')}
</Link>
</li>

<li className="nl-simple" aria-haspopup="true">
<Link
href="/ecosystem"
onClick={handleMobileMenu}
className="h-link"
className="h-link text-start"
locale={router.locale}
style={{ textAlign: "left" }}
>
Ecosystem
{t('ecosystem')}
</Link>
</li>

<li className="nl-simple" aria-haspopup="true">
<Link href="/#roadmap" onClick={handleMobileMenu} className="h-link">
Roadmap
<Link href="/#roadmap" onClick={handleMobileMenu} locale={router.locale} className="h-link text-start" style={{ textAlign: "left" }}>
{t('roadmap')}
</Link>
</li>

<li className="nl-simple" aria-haspopup="true">
<Link href="/team" onClick={handleMobileMenu} className="h-link">
Team
<Link href="/team" onClick={handleMobileMenu} locale={router.locale} className="h-link text-start" style={{ textAlign: "left" }}>
{t('team')}
</Link>
</li>

<li className="nl-simple" aria-haspopup="true">
<Link
legacyBehavior
href="https://github.com/koinos"
onClick={handleMobileMenu}
target="_blank"
passHref
rel="noopener noreferrer"
onClick={handleMobileMenu}
>
<a target="_blank" rel="noopener noreferrer">
<img
src="/images/menu/github-mark.svg"
alt="GitHub"
style={{ width: "30px", height: "30px" }}
className="light-theme-img"
/>
<img
src="/images/menu/github-mark-white.svg"
alt="GitHub"
style={{ width: "30px", height: "30px" }}
className="dark-theme-img"
/>
</a>
<img
src="/images/menu/github-mark.svg"
alt="GitHub"
style={{ width: "30px", height: "30px" }}
className="light-theme-img"
/>
<img
src="/images/menu/github-mark-white.svg"
alt="GitHub"
style={{ width: "30px", height: "30px" }}
className="dark-theme-img"
/>
</Link>
</li>

<li className="nl-simple" aria-haspopup="true">
<div className="language-switcher py-2 px-3 text-start">
<div className="d-flex align-items-center" onClick={() => setIsLangDropdownOpen(!isLangDropdownOpen)}>
<i className="fa-solid fa-globe me-2"></i>
<span>{router.locale === 'en' ? 'English' : 'Español'}</span>
</div>

{isLangDropdownOpen && (
<div className="ms-4 mt-2">
<div>
<Link
href={router.asPath}
locale="en"
className={`d-block py-1 text-decoration-none ${router.locale === 'en' ? 'active' : ''}`}
onClick={() => {
setIsLangDropdownOpen(false)
handleMobileMenu()
}}
>
English
</Link>
</div>
<div>
<Link
href={router.asPath}
locale="es"
className={`d-block py-1 text-decoration-none ${router.locale === 'es' ? 'active' : ''}`}
onClick={() => {
setIsLangDropdownOpen(false)
handleMobileMenu()
}}
>
Español
</Link>
</div>
<div>
<Link
href={router.asPath}
locale="it"
className={`d-block py-1 text-decoration-none ${router.locale === 'es' ? 'active' : ''}`}
onClick={() => {
setIsLangDropdownOpen(false)
handleMobileMenu()
}}
>
Italiano
</Link>
</div>
<div>
<Link
href={router.asPath}
locale="fa"
className={`d-block py-1 text-decoration-none ${router.locale === 'es' ? 'active' : ''}`}
onClick={() => {
setIsLangDropdownOpen(false)
handleMobileMenu()
}}
>
فارسی
</Link>
</div>
</div>
)}
</div>
</li>
</ul>
</>
);
Expand Down
Loading