diff --git a/i18n.json b/i18n.json deleted file mode 100644 index 0133d43..0000000 --- a/i18n.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "locales": ["en", "ja"], - "defaultLocale": "ja", - "pages": { - "*": ["common"], - "/": ["index", "minecraft", "common"], - "/profile": ["profile", "common"], - "/server": ["server", "common"], - "/house": ["house", "common"], - "/tos": ["tos", "common"], - "/hcunews": ["hcunews", "common"], - "/minecraft": ["minecraft", "common"], - "/404": ["404", "common"] - } - } \ No newline at end of file diff --git a/i18n/index.js b/i18n/index.js new file mode 100644 index 0000000..67d9452 --- /dev/null +++ b/i18n/index.js @@ -0,0 +1,12 @@ +var ja = require('./translations.en.json'); +var en = require('./translations.ja.json') + +const i18n = { + translations: { + ja: ja, + en: en, + }, + defaultLang: 'ja' +} + +module.exports = i18n; \ No newline at end of file diff --git a/i18n/translations.en.json b/i18n/translations.en.json new file mode 100644 index 0000000..63b6335 --- /dev/null +++ b/i18n/translations.en.json @@ -0,0 +1,64 @@ +{ + "caption": "The requested page does not exist on this website.", + "return": "Return to top", + "footer": "This page is provided under the MIT License.", + "source": "Source code", + "tos": "yude.jp Terms of Service", + "yes_playing": "Playing {{playing}}", + "listening": "Listening to {{listening}}", + "close": "Close", + "mutual": "Mutual links", + "status": "Service Status", + "icon_1": "Icon: ", + "icon_2": "", + "post_list": "Posts listing", + "hcunews": "About @hcunews", + "house": "yude's house", + "home": "Home", + "profile": "yude's profile", + "blog": "yude's blog", + "status": "yude.jp Server Status", + "house": "yude's house", + "discord": "yude.jp Discord Server", + "mastodon": "Mastodon instance", + "title": "Minecraft Multiplayer", + "playing": "{{count}} player(s) online.", + "no_one": "No one is playing.", + "offline": "Server is down.", + "address": "Server address", + "fail": "Failed to retrieve server status.", + "loading": "Retrieving server status...", + "version": "Version", + "about": "About yude", + "desc": "Description", + "school": "Faculty of Information Science, Hiroshima City University.", + "hiroshima": "Hiroshima, Japan", + "location": "Location", + "link": "Links", + "link_all": "To see all of yude's account, please visit ", + "link_all_late": ".", + "here": "here", + "mail": "E-mail", + "birth": "Birthday", + "date": "November the 19th, 2001", + "contact": "Accounts", + "belongs": "Organization", + "grade": "B2", + "keys": "Public keys", + "download": "Download", + "fingerprint": "Digital fingerprint", + "view": "View", + "device": "Devices", + "account": "Accounts", + "wishlist": "Amazon Wishlist", + "status": "Server Status", + "location": "Location", + "tottori": "Tottori, Japan", + "hiroshima": "Hiroshima, Japan", + "model": "Model", + "region": "Region", + "service": "Service", + "shape": "Shape", + "tos": "yude.jp Terms of Service", + "input": "en" +} \ No newline at end of file diff --git a/i18n/translations.ja.json b/i18n/translations.ja.json new file mode 100644 index 0000000..08ac0dc --- /dev/null +++ b/i18n/translations.ja.json @@ -0,0 +1,64 @@ +{ + "caption": "要求されたページはこのウェブサイト上に存在しません。", + "return": "トップページへ戻る", + "footer": "このページは MIT License のもと提供されています。", + "source": "ソースコード", + "tos": "yude.jp サービス利用規約", + "yes_playing": "{{playing}} をプレイ中", + "listening": "{{listening}} を再生中", + "close": "閉じる", + "mutual": "相互リンク", + "status": "サービスの状態", + "icon_1": "アイコン: ", + "icon_2": "さん", + "post_list": "記事一覧", + "hcunews": "@hcunews について", + "house": "ゆでハウス", + "home": "ホーム", + "profile": "yude のプロフィール", + "blog": "yude のブログ", + "status": "yude.jp サーバー情報", + "house": "ゆでハウス", + "discord": "yude.jp Discord サーバー", + "mastodon": "Mastodon インスタンス", + "title": "Minecraft マルチプレイ", + "playing": "{{count}} 人がプレイしています。", + "no_one": "現在、誰もログインしていません。", + "offline": "サーバーがオフラインのようです。", + "address": "サーバー アドレス", + "fail": "サーバーの状態を取得できませんでした。", + "loading": "サーバーの状態を取得しています...", + "version": "バージョン", + "about": "yude について", + "desc": "概要", + "school": "広島市立大学 情報科学部", + "hiroshima": "日本, 広島県", + "location": "所在地", + "link": "リンク", + "link_all": "yude が所持しているすべてのアカウントの一覧は、", + "link_all_late": "にあります。", + "here": "こちら", + "mail": "メール", + "birth": "生年月日", + "date": "2001年11月19日", + "contact": "アカウント", + "belongs": "所属", + "grade": "2年", + "keys": "公開鍵", + "download": "ダウンロード", + "fingerprint": "電子指紋", + "view": "閲覧", + "device": "デバイス", + "account": "アカウント", + "wishlist": "Amazon ほしいものリスト", + "status": "サーバー情報", + "location": "場所", + "tottori": "日本, 鳥取県", + "hiroshima": "日本, 広島県", + "model": "モデル", + "region": "リージョン", + "service": "サービス", + "shape": "シェイプ", + "tos": "yude.jp サービス利用規約", + "input": "ja" +} \ No newline at end of file diff --git a/locales/en/404.json b/locales/en/404.json deleted file mode 100644 index d29c078..0000000 --- a/locales/en/404.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "caption": "The requested page does not exist on this website.", - "return": "Return to top" -} \ No newline at end of file diff --git a/locales/en/common.json b/locales/en/common.json deleted file mode 100644 index b84fd24..0000000 --- a/locales/en/common.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "footer": "This page is provided under the MIT License.", - "source": "Source code", - "tos": "yude.jp Terms of Service", - "yes_playing": "Playing {{playing}}", - "listening": "Listening to {{listening}}", - "close": "Close", - "mutual": "Mutual links", - "status": "Service Status", - "icon_1": "Icon: ", - "icon_2": "", - "post_list": "Posts listing" -} \ No newline at end of file diff --git a/locales/en/hcunews.json b/locales/en/hcunews.json deleted file mode 100644 index 6910cad..0000000 --- a/locales/en/hcunews.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "hcunews": "About @hcunews" -} \ No newline at end of file diff --git a/locales/en/house.json b/locales/en/house.json deleted file mode 100644 index e9e0959..0000000 --- a/locales/en/house.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "house": "yude's house" -} \ No newline at end of file diff --git a/locales/en/index.json b/locales/en/index.json deleted file mode 100644 index 3b2d15e..0000000 --- a/locales/en/index.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "home": "Home", - "profile": "yude's profile", - "blog": "yude's blog", - "status": "yude.jp Server Status", - "house": "yude's house", - "discord": "yude.jp Discord Server", - "mastodon": "Mastodon instance" -} \ No newline at end of file diff --git a/locales/en/minecraft.json b/locales/en/minecraft.json deleted file mode 100644 index 661eeeb..0000000 --- a/locales/en/minecraft.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "title": "Minecraft Multiplayer", - "playing": "{{count}} player(s) online.", - "no_one": "No one is playing.", - "offline": "Server is down.", - "address": "Server address", - "fail": "Failed to retrieve server status.", - "loading": "Retrieving server status...", - "version": "Version" -} \ No newline at end of file diff --git a/locales/en/profile.json b/locales/en/profile.json deleted file mode 100644 index 701546f..0000000 --- a/locales/en/profile.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "about": "About yude", - "desc": "Description", - "school": "Faculty of Information Science, Hiroshima City University.", - "hiroshima": "Hiroshima, Japan", - "location": "Location", - "link": "Links", - "link_all": "To see all of yude's account, please visit ", - "link_all_late": ".", - "here": "here", - "mail": "E-mail", - "birth": "Birthday", - "date": "November the 19th, 2001", - "contact": "Accounts", - "belongs": "Organization", - "grade": "B2", - "keys": "Public keys", - "download": "Download", - "fingerprint": "Digital fingerprint", - "view": "View", - "device": "Devices", - "account": "Accounts", - "wishlist": "Amazon Wishlist" -} \ No newline at end of file diff --git a/locales/en/server.json b/locales/en/server.json deleted file mode 100644 index c28d282..0000000 --- a/locales/en/server.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "status": "Server Status", - "location": "Location", - "tottori": "Tottori, Japan", - "hiroshima": "Hiroshima, Japan", - "model": "Model", - "region": "Region", - "service": "Service", - "shape": "Shape" -} \ No newline at end of file diff --git a/locales/en/tos.json b/locales/en/tos.json deleted file mode 100644 index 25fa453..0000000 --- a/locales/en/tos.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "tos": "yude.jp Terms of Service", - "input": "en" -} \ No newline at end of file diff --git a/locales/ja/404.json b/locales/ja/404.json deleted file mode 100644 index fa12291..0000000 --- a/locales/ja/404.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "caption": "要求されたページはこのウェブサイト上に存在しません。", - "return": "トップページへ戻る" -} \ No newline at end of file diff --git a/locales/ja/common.json b/locales/ja/common.json deleted file mode 100644 index dd30120..0000000 --- a/locales/ja/common.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "footer": "このページは MIT License のもと提供されています。", - "source": "ソースコード", - "tos": "yude.jp サービス利用規約", - "yes_playing": "{{playing}} をプレイ中", - "listening": "{{listening}} を再生中", - "close": "閉じる", - "mutual": "相互リンク", - "status": "サービスの状態", - "icon_1": "アイコン: ", - "icon_2": "さん", - "post_list": "記事一覧" -} \ No newline at end of file diff --git a/locales/ja/hcunews.json b/locales/ja/hcunews.json deleted file mode 100644 index d659c7c..0000000 --- a/locales/ja/hcunews.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "hcunews": "@hcunews について" -} \ No newline at end of file diff --git a/locales/ja/house.json b/locales/ja/house.json deleted file mode 100644 index 65fbbc9..0000000 --- a/locales/ja/house.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "house": "ゆでハウス" -} \ No newline at end of file diff --git a/locales/ja/index.json b/locales/ja/index.json deleted file mode 100644 index 2c64389..0000000 --- a/locales/ja/index.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "home": "ホーム", - "profile": "yude のプロフィール", - "blog": "yude のブログ", - "status": "yude.jp サーバー情報", - "house": "ゆでハウス", - "discord": "yude.jp Discord サーバー", - "mastodon": "Mastodon インスタンス" -} \ No newline at end of file diff --git a/locales/ja/minecraft.json b/locales/ja/minecraft.json deleted file mode 100644 index 3a2a5cf..0000000 --- a/locales/ja/minecraft.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "title": "Minecraft マルチプレイ", - "playing": "{{count}} 人がプレイしています。", - "no_one": "現在、誰もログインしていません。", - "offline": "サーバーがオフラインのようです。", - "address": "サーバー アドレス", - "fail": "サーバーの状態を取得できませんでした。", - "loading": "サーバーの状態を取得しています...", - "version": "バージョン" -} \ No newline at end of file diff --git a/locales/ja/profile.json b/locales/ja/profile.json deleted file mode 100644 index b715444..0000000 --- a/locales/ja/profile.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "about": "yude について", - "desc": "概要", - "school": "広島市立大学 情報科学部", - "hiroshima": "日本, 広島県", - "location": "所在地", - "link": "リンク", - "link_all": "yude が所持しているすべてのアカウントの一覧は、", - "link_all_late": "にあります。", - "here": "こちら", - "mail": "メール", - "birth": "生年月日", - "date": "2001年11月19日", - "contact": "アカウント", - "belongs": "所属", - "grade": "2年", - "keys": "公開鍵", - "download": "ダウンロード", - "fingerprint": "電子指紋", - "view": "閲覧", - "device": "デバイス", - "account": "アカウント", - "wishlist": "Amazon ほしいものリスト" -} \ No newline at end of file diff --git a/locales/ja/server.json b/locales/ja/server.json deleted file mode 100644 index e6c7e17..0000000 --- a/locales/ja/server.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "status": "サーバー情報", - "location": "場所", - "tottori": "日本, 鳥取県", - "hiroshima": "日本, 広島県", - "model": "モデル", - "region": "リージョン", - "service": "サービス", - "shape": "シェイプ" -} \ No newline at end of file diff --git a/locales/ja/tos.json b/locales/ja/tos.json deleted file mode 100644 index 25b274d..0000000 --- a/locales/ja/tos.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "tos": "yude.jp サービス利用規約", - "input": "ja" -} \ No newline at end of file diff --git a/next.config.js b/next.config.js index 66869c3..94bcfeb 100644 --- a/next.config.js +++ b/next.config.js @@ -1,5 +1,3 @@ -const nextTranslate = require('next-translate') - const rewrites = async () => { return [ { @@ -13,11 +11,7 @@ const rewrites = async () => { ] } -module.exports = nextTranslate({ - i18n: { - locales: ['ja', 'en'], - defaultLocale: 'ja', - }, +module.exports = { images: { domains: ['mackerel.io', 'mc-heads.net', 'crafatar.com'], }, @@ -43,4 +37,4 @@ module.exports = nextTranslate({ ] }, rewrites, - }) \ No newline at end of file + } \ No newline at end of file diff --git a/package.json b/package.json index 8f4a3f2..61a1c0a 100644 --- a/package.json +++ b/package.json @@ -34,9 +34,10 @@ "microcms-js-sdk": "^1.2.0", "moment": "^2.29.1", "next": "^11.1.3", + "next-export-i18n": "^1.2.1", "next-seo": "^4.28.1", "next-themes": "^0.0.15", - "next-translate": "^1.1.0", + "next-translate": "^1.2.0", "popper.js": "^1.16.1", "postcss": "^8.3.6", "prop-types": "^15.7.2", diff --git a/pages/404.js b/pages/404.js deleted file mode 100644 index 94b9426..0000000 --- a/pages/404.js +++ /dev/null @@ -1,29 +0,0 @@ -// Base layout -import Layout from "./components/Layout" - -// React Router -import { useRouter } from 'next/router' - -// Next.js -import Link from 'next/link' -import useTranslation from 'next-translate/useTranslation' - -export default function Custom404(props) { - const router = useRouter() - const { locale, locales, defaultLocale, pathname } = router - const { t, lang } = useTranslation("404") - - return ( - -
-

404

-

{t('caption')}

- - -

{t('return')}

-
- -
-
- ) -} \ No newline at end of file diff --git a/pages/components/Discord/DiscordPlaying.js b/pages/components/Discord/DiscordPlaying.js index 9badba3..c59feb7 100644 --- a/pages/components/Discord/DiscordPlaying.js +++ b/pages/components/Discord/DiscordPlaying.js @@ -4,9 +4,6 @@ import useTranslation from 'next-translate/useTranslation' import { useRouter } from 'next/router' function App (){ - const router = useRouter() - const { locale, locales, defaultLocale, pathname } = router - const { t, lang } = useTranslation("common") const [data, setData] = useState({ hits: [] }); useEffect(() => { const fetchData = async () => { diff --git a/pages/components/Footer/Footer.js b/pages/components/Footer/Footer.js index 50fc92a..7ff65af 100644 --- a/pages/components/Footer/Footer.js +++ b/pages/components/Footer/Footer.js @@ -1,13 +1,9 @@ import "tailwindcss/tailwind.css"; import Link from 'next/link'; -import useTranslation from 'next-translate/useTranslation' -import { useRouter } from 'next/router' -export default function Footer(props) { - - const router = useRouter() - const { locale, locales, defaultLocale, pathname } = router - const { t, lang } = useTranslation("common") +// i18n +import { useTranslation, useLanguageQuery, LanguageSwitcher } from 'next-export-i18n'; +export default function Footer(props) { return ( <>
diff --git a/pages/components/LangSelector.js b/pages/components/LangSelector.js index 804dcbe..1db6d59 100644 --- a/pages/components/LangSelector.js +++ b/pages/components/LangSelector.js @@ -6,9 +6,6 @@ import { faLanguage } from '@fortawesome/free-solid-svg-icons' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' const Dropdown = ({ color }) => { - const router = useRouter() - const { locale, locales, defaultLocale, pathname } = router - // dropdown props const [dropdownPopoverShow, setDropdownPopoverShow] = React.useState(false); const btnDropdownRef = React.createRef(); diff --git a/pages/components/Layout.js b/pages/components/Layout.js index 10b7d47..459dd1f 100644 --- a/pages/components/Layout.js +++ b/pages/components/Layout.js @@ -1,21 +1,19 @@ +// Next.js import Head from "next/head" + +// Tailwind CSS import "tailwindcss/tailwind.css"; -import useTranslation from 'next-translate/useTranslation' -import { useRouter } from 'next/router' + +// React import React, { useEffect, useState } from 'react' + +// Components import Footer from "./Footer/Footer" import Navbar from "./Navbar" const Layout = (props) => { const { title, children } = props const siteTitle = "yude.jp" - const router = useRouter() - const { locale, locales, defaultLocale, pathname } = router - - const { t, lang } = useTranslation("common") - const footer = t('footer') - const source = t('source') - const tos = t('tos') return (
diff --git a/pages/components/Minecraft.js b/pages/components/Minecraft.js index b616fa4..1c6fb20 100644 --- a/pages/components/Minecraft.js +++ b/pages/components/Minecraft.js @@ -6,10 +6,6 @@ import Image from 'next/image' import { list } from 'postcss'; export default function Minecraft(props) { - const router = useRouter() - const { locale, locales, defaultLocale, pathname } = router - const { t, lang } = useTranslation("minecraft") - const [data, setData] = useState({ hits: [] }); useEffect(() => { diff --git a/pages/components/Minecraft/Online.js b/pages/components/Minecraft/Online.js index 53fa1e5..e029ed4 100644 --- a/pages/components/Minecraft/Online.js +++ b/pages/components/Minecraft/Online.js @@ -6,9 +6,6 @@ import LastPlayed from './LastPlayed' function App (props) { const uuid = props; - const router = useRouter() - const { locale, locales, defaultLocale, pathname } = router - const { t, lang } = useTranslation("common") const [data, setData] = useState({ hits: [] }); useEffect(() => { diff --git a/pages/components/Navbar.js b/pages/components/Navbar.js index 1cabdf5..dd8c912 100644 --- a/pages/components/Navbar.js +++ b/pages/components/Navbar.js @@ -16,7 +16,8 @@ const Navbar = () => {
- + {/* */} +
diff --git a/pages/components/Profile/PublicKeys.js b/pages/components/Profile/PublicKeys.js index 367a79c..d7152ab 100644 --- a/pages/components/Profile/PublicKeys.js +++ b/pages/components/Profile/PublicKeys.js @@ -8,8 +8,6 @@ import Link from 'next/link' export default function Modal() { const [showModal, setShowModal] = React.useState(false); const router = useRouter() - const { t, lang } = useTranslation("common") - const { locale, locales, defaultLocale, pathname } = router const close = t('common:close') const keys = t('profile:keys') const view = t('profile:view') diff --git a/pages/components/Profile/Spotify.js b/pages/components/Profile/Spotify.js index 76ff401..8385750 100644 --- a/pages/components/Profile/Spotify.js +++ b/pages/components/Profile/Spotify.js @@ -4,9 +4,6 @@ import useTranslation from 'next-translate/useTranslation' import { useRouter } from 'next/router' function App () { - const router = useRouter() - const { locale, locales, defaultLocale, pathname } = router - const { t, lang } = useTranslation("common") const [data, setData] = useState({ hits: [] }); useEffect(() => { const fetchData = async () => { diff --git a/pages/components/Profile/WakaTime.js b/pages/components/Profile/WakaTime.js index 79397c3..c91604d 100644 --- a/pages/components/Profile/WakaTime.js +++ b/pages/components/Profile/WakaTime.js @@ -6,10 +6,7 @@ import { useRouter } from 'next/router' export default function Modal() { const [showModal, setShowModal] = React.useState(false); - const router = useRouter() - const { locale, locales, defaultLocale, pathname } = router - const { t, lang } = useTranslation("common") - const close = t('common:close') + return ( <>