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

feat: localize #30

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 12 additions & 10 deletions components/About.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
import { FC } from 'react'
import styles from '../static/Section.module.scss'
import { useLocale } from '../hooks/useLocale'

const About: FC = () => {
const { t } = useLocale()
return (
<section id={'about'} className={styles.section}>
<h2>{'About'}</h2>
<h2>{t.about}</h2>
<div className={styles.detail}>
<dl>
<dt>開催日時</dt>
<dd>2021年 11月 20日</dd>
<dt>{t.date_and_time}</dt>
<dd>{t.november_20_2021}</dd>
</dl>
<dl>
<dt>会場</dt>
<dd>オンライン</dd>
<dt>{t.venue}</dt>
<dd>{t.online}</dd>
</dl>
<dl>
<dt>参加費</dt>
<dd>無料</dd>
<dt>{t.entry_fee}</dt>
<dd>{t.free}</dd>
</dl>
<dl>
<dt>参加方法</dt>
<dt>{t.way_to_participate}</dt>
<dd>
<a
href="https://vscode.connpass.com/event/221961/"
aria-label="connpass フォームより参加を申し込む"
aria-label={t.apply_for_participation_from_connpass_form}
target="_blank"
rel="noopener noreferrer"
>
connpass フォームより参加を申し込む
{t.apply_for_participation_from_connpass_form}
</a>
</dd>
</dl>
Expand Down
8 changes: 5 additions & 3 deletions components/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { FC } from 'react'
import Link from 'next/link'
import styles from '../static/Footer.module.scss'
import { useLocale } from '../hooks/useLocale'
import { organizationName } from '../utils/constants'

const Footer: FC = () => {
const { t } = useLocale()
return (
<footer className={styles.footer}>
<p className={styles.contact}>
<Link href="/code-for-conduct">{'行動規範'}</Link>
<Link href="/privacy-policy">{'プライバシーポリシー'}</Link>
<Link href="/contact">{'問い合わせ'}</Link>
<Link href="/code-for-conduct">{t.code_of_conduct}</Link>
<Link href="/privacy-policy">{t.privacy_policy}</Link>
<Link href="/contact">{t.contact}</Link>
</p>
<p className={styles.copyright}>
{`Created © 2021 ${organizationName}. All Rights Reserved.`}
Expand Down
18 changes: 10 additions & 8 deletions components/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,36 @@
import { FC } from 'react'
import Link from 'next/link'
import styles from '../static/Header.module.scss'
import { useLocale } from '../hooks/useLocale'
import { conferenceName } from '../utils/constants'

import { ColorThemeSwitch } from './ColorThemeSwitch'

const Header: FC = () => {
const { t } = useLocale()
return (
<div className={styles.header}>
<Link href="/">
<a className={styles.logo}>{conferenceName}</a>
</Link>
<div className={styles.linksWrapper}>
<div className={styles.wrapper}>
<nav className={styles.links}>
<Link href="/#about">
<a className={styles.link}>{'About'}</a>
<a className={styles.link}>{t.about}</a>
</Link>
<Link href="/#speakers">
<a className={styles.link}>{'Speakers'}</a>
<a className={styles.link}>{t.speakers}</a>
</Link>
<Link href="/#timetable">
<a className={styles.link}>{'Timetable'}</a>
<a className={styles.link}>{t.timetable}</a>
</Link>
<Link href="/#staffs">
<a className={styles.link}>{'Staffs'}</a>
<a className={styles.link}>{t.staffs}</a>
</Link>
<a href="#" className={styles.link}>
<ColorThemeSwitch />
</a>
</nav>
<a href="#" className={styles.link}>
<ColorThemeSwitch />
</a>
</div>
</div>
)
Expand Down
6 changes: 4 additions & 2 deletions components/Speakers.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { FC } from 'react'
import styles from '../static/Section.module.scss'
import { useLocale } from '../hooks/useLocale'

const Speakers: FC = () => {
const { t } = useLocale()
return (
<section id={'speakers'} className={styles.section}>
<h2>{'Speakers'}</h2>
<h3>{'Coming soon'}</h3>
<h2>{t.speakers}</h2>
<h3>{t.coming_soon}</h3>
</section>
)
}
Expand Down
4 changes: 3 additions & 1 deletion components/Staffs.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { FC } from 'react'
// import Image from 'next/image'
import styles from '../static/Staff.module.scss'
import { useLocale } from '../hooks/useLocale'
import { members } from '../contents/members'

const Staffs: FC = () => {
const { t } = useLocale()
return (
<section id={'staffs'} className={styles.section}>
<h2>{'Staffs'}</h2>
<h2>{t.staffs}</h2>
<div className={styles.staffs}>
{members.map((member) => {
return (
Expand Down
6 changes: 4 additions & 2 deletions components/Timetable.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { FC } from 'react'
import styles from '../static/Section.module.scss'
import { useLocale } from '../hooks/useLocale'

// import Schedule from './Schedule'

const Timetable: FC = () => {
const { t } = useLocale()
return (
<section id={'timetable'} className={styles.section}>
<h2>{'Timetable'}</h2>
<h3>{'Coming soon'}</h3>
<h2>{t.timetable}</h2>
<h3>{t.coming_soon}</h3>
</section>
)
}
Expand Down
10 changes: 10 additions & 0 deletions hooks/useLocale.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { useRouter } from 'next/router'

import en from '../public/locales/en'
import ja from '../public/locales/ja'

export const useLocale = () => {
const { locale } = useRouter()
const t = locale === 'en' ? en : ja
return { locale, t }
}
4 changes: 4 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ const nextConfig = {
subdomainPrefix: urlPrefix,
runtimeCaching,
},
i18n: {
defaultLocale: 'en',
locales: ['en', 'ja'],
},
exportPathMap: async function (defaultPathMap, { dev, dir, outDir, distDir, buildId }) {
return {
'/': { page: '/' },
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"test:w": "npm run test-cover -- --watch"
},
"dependencies": {
"next": "11.0.1",
"next": "9.5.5",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-markdown": "^5.0.3"
Expand Down
20 changes: 20 additions & 0 deletions public/locales/en.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export default {
en: 'EN',
ja: 'JA',
coming_soon: 'Coming Soon',
about: 'About',
date_and_time: 'Date and time',
november_20_2021: 'November 20, 2021',
venue: 'Venue',
online: 'Online',
entry_fee: 'Entry fee',
free: 'Free',
way_to_participate: 'Way to participate',
apply_for_participation_from_connpass_form: 'Apply for participation from connpass form',
timetable: 'Timetable',
speakers: 'Speakers',
staffs: 'Staffs',
code_of_conduct: 'Code of Conduct',
privacy_policy: 'Privacy Policy',
contact: 'Contact',
}
20 changes: 20 additions & 0 deletions public/locales/ja.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export default {
en: '英',
ja: '日',
coming_soon: '募集中',
about: '詳細',
date_and_time: '開催日時',
november_20_2021: '2021年 11月 20日',
venue: '会場',
online: 'オンライン',
entry_fee: '参加費',
free: '無料',
way_to_participate: '参加方法',
apply_for_participation_from_connpass_form: 'connpass フォームより参加を申し込む',
timetable: 'タイムテーブル',
speakers: 'スピーカー',
staffs: 'スタッフ',
code_of_conduct: '行動規範',
privacy_policy: 'プライバシーポリシー',
contact: 'お問い合わせ',
}
17 changes: 16 additions & 1 deletion static/Header.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
font-size: 1.6rem;
}

.links-wrapper {
.wrapper {
display: flex;
align-items: center;
}

.links {
font-size: min(1.6vw, 24px);
margin-right: min(2.4vw, 48px);
}

.link:not(:last-of-type) {
Expand All @@ -39,3 +40,17 @@
opacity: 1;
font-family: AvenirNextLTPro-BoldCn, sans-serif;
}

@media (max-width: 600px) {
.logo {
font-size: 1.08rem;
}

.wrapper {
flex-direction: row;
}

.links {
display: none;
}
}