-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from unchain-tech/feat/bilingual
二言語対応(日英)
- Loading branch information
Showing
30 changed files
with
528 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { I18nConfig } from 'next-translate'; | ||
|
||
export const i18nConfig = { | ||
locales: ['en', 'ja'], | ||
defaultLocale: 'ja', | ||
loader: false, | ||
pages: { | ||
'*': ['common'], | ||
}, | ||
defaultNS: 'common', | ||
} satisfies I18nConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"LOCALESWITCH": "ja", | ||
"MENU": { "LANGUAGE": "日本語" }, | ||
"TOP": { | ||
"INTRO": "UNCHAIN is a grassroots community of web3 engineers, turning to their ideas into reality." | ||
}, | ||
"PROJECTS": { | ||
"1": "Hands-on tutorials to help you understand how to build dApps on public blockchains.", | ||
"2": "Completely free and open-source." | ||
}, | ||
"VALUES": { | ||
"1": { | ||
"HEADING": "Project-Based Learning", | ||
"DESCRIPTION": "Gain practical development skills in smart contracts and web applications through a wide range of hands-on, project based tutorials." | ||
}, | ||
"2": { | ||
"HEADING": "Community Growth", | ||
"DESCRIPTION": "Find other people with similar passions, and share ideas with each other for mutual growth." | ||
}, | ||
"3": { | ||
"HEADING": "Open-Source", | ||
"DESCRIPTION": "Anyone can see and verify our projects, and even contribute to it themselves. Everything is provided free and to the public." | ||
} | ||
}, | ||
"CONTACT": { | ||
"TITLE": "CONTACT FORM" | ||
}, | ||
"PRIVACYPOLICY": "Privacy Policy" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"LOCALESWITCH": "en", | ||
"MENU": { "LANGUAGE": "English" }, | ||
"TOP": { | ||
"INTRO": "UNCHAINは、プロジェクト開発を通して技術を学び、実践経験を積むことで自分のアイデアを形にする力を身につける、エンジニアのための有志コミュニティです。" | ||
}, | ||
"PROJECTS": { | ||
"1": "public chain上でdApp開発を実践できる、25の開発プロジェクトをオープンソースで提供", | ||
"2": "完全無料・オープンソース" | ||
}, | ||
"VALUES": { | ||
"1": { | ||
"HEADING": "プロジェクト型の学習", | ||
"DESCRIPTION": "プロジェクト型の学習コンテンツを通して、スマートコントラクトやweb開発の実践的なスキルを身につけることができます。" | ||
}, | ||
"2": { | ||
"HEADING": "共に学ぶコミュニティ", | ||
"DESCRIPTION": "同じ興味や志を持つ仲間を見つけ、互いの知見を共有し合うことで、切磋琢磨することができます。" | ||
}, | ||
"3": { | ||
"HEADING": "オープンソース", | ||
"DESCRIPTION": "誰でもソースコードを検証し、必要とあれば追記編集することができます。コンテンツは全て無料で公開されています。" | ||
} | ||
}, | ||
"CONTACT": { | ||
"TITLE": "問い合わせフォーム" | ||
}, | ||
"PRIVACYPOLICY": "プライバシーポリシー" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import NextLink from 'next/link'; | ||
import { useRouter } from 'next/router'; | ||
import type { ReactNode } from 'react'; | ||
|
||
interface LinkProps { | ||
children: ReactNode; | ||
skipLocaleHandling?: boolean; | ||
locale?: string; | ||
href: string; | ||
target?: string; | ||
} | ||
|
||
export const Link = ({ | ||
children, | ||
skipLocaleHandling, | ||
target, | ||
...rest | ||
}: LinkProps) => { | ||
const router = useRouter(); | ||
const locale = rest.locale || (router.query.locale as string) || ''; | ||
|
||
let href = rest.href || router.asPath; | ||
if (href.indexOf('http') === 0) skipLocaleHandling = true; | ||
if (locale && !skipLocaleHandling) { | ||
href = href | ||
? `/${locale}${href}` | ||
: router.pathname.replace('[locale]', locale); | ||
} | ||
|
||
return ( | ||
<NextLink href={href} target={target}> | ||
{children} | ||
</NextLink> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import Link from 'next/link'; | ||
import { useRouter } from 'next/router'; | ||
|
||
import { languageDetector } from '@/lib/languageDetector'; | ||
|
||
interface LanguageSwitcherProps { | ||
locale: string; | ||
href?: string; | ||
asPath?: string; | ||
} | ||
|
||
export const LanguageSwitcher = ({ | ||
locale, | ||
...rest | ||
}: LanguageSwitcherProps) => { | ||
const router = useRouter(); | ||
|
||
let href = rest.href || router.asPath; | ||
let pName = router.pathname; | ||
// biome-ignore lint/complexity/noForEach: readability | ||
Object.keys(router.query).forEach((k) => { | ||
if (k === 'locale') { | ||
pName = pName.replace(`[${k}]`, locale); | ||
return; | ||
} | ||
pName = pName.replace(`[${k}]`, String(router.query[k])); | ||
}); | ||
if (locale) { | ||
href = rest.href ? `/${locale}${rest.href}` : pName; | ||
} | ||
|
||
return ( | ||
<Link | ||
href={href} | ||
onClick={() => | ||
languageDetector.cache ? languageDetector.cache(locale) : {} | ||
} | ||
> | ||
<button type="button"> | ||
<p className="text-xl">{locale}</p> | ||
</button> | ||
</Link> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import useTranslation from 'next-translate/useTranslation'; | ||
|
||
import { i18nConfig } from '../../i18n'; | ||
|
||
interface IUseI18n { | ||
namespace?: string; | ||
} | ||
|
||
export const useI18n = ({ namespace }: IUseI18n = {}) => { | ||
const { t } = useTranslation(namespace ? namespace : i18nConfig.defaultNS); | ||
return { t }; | ||
}; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.