Skip to content
This repository has been archived by the owner on Aug 6, 2024. It is now read-only.

Commit

Permalink
Add: Init i18n(#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Nov 16, 2022
1 parent f0157c8 commit 02984d5
Show file tree
Hide file tree
Showing 12 changed files with 99 additions and 7 deletions.
6 changes: 6 additions & 0 deletions next-i18next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
i18n: {
defaultLocale: 'ja',
locales: ['ja', 'en', 'zh'],
},
};
2 changes: 2 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ const withTM = require("next-transpile-modules")([
"@react-dnd/asap",
"@react-dnd/shallowequal",
])
const { i18n } = require('./next-i18next.config');


module.exports = withPlugins([withTM, withPWA], {
i18n,
reactStrinctMode: true,
experimental: {
esmExternals: "loose",
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"md5": "^2.3.0",
"multer": "^1.4.5-lts.1",
"next": "12.3.1",
"next-i18next": "^12.1.0",
"next-pwa": "^5.6.0",
"next-transpile-modules": "^9.1.0",
"nookies": "^2.5.2",
Expand Down
3 changes: 2 additions & 1 deletion pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import React from "react";
import UserInfoProvider from "../components/auth/userInfoProvider";
import useTransition from "../components/hooks/useTransition";
import { SiteName } from "../components/core/const"
import { appWithTranslation } from 'next-i18next';

function MyApp({ Component, pageProps }: AppProps) {
useTransition();
Expand All @@ -18,4 +19,4 @@ function MyApp({ Component, pageProps }: AppProps) {
);
}

export default MyApp;
export default appWithTranslation(MyApp);
17 changes: 13 additions & 4 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ import TagImages from "../components/common/tagimages"
import Challenge from "../components/common/challange"
import ChallengeImages from "../components/common/challengeimages"
import Head from "next/head";

import { useTranslation, Trans } from 'next-i18next'
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
import { GetStaticProps } from "next";

const fetcher = (url) => fetch(url).then((r) => r.json());

Expand All @@ -42,12 +44,13 @@ const Meta = () => {
)
}

export default function App() {
export default function App(_props) {
var ctx = useContext(userInfoContext);
var access_limit = ""
const router = useRouter();
const [follows, setfollows] = useState("()")
const [isloading, setisloading] = useState(false);
const { t } = useTranslation('home')

if (ctx.UserInfo !== null) {
access_limit = "?" + new URLSearchParams(ctx.UserInfo.access_limit).toString()
Expand Down Expand Up @@ -104,7 +107,7 @@ export default function App() {
<div>
<div className="mx-auto max-w-7xl py-8 px-4 sm:px-10">
<div className="mt-6 text-xl font-semibold dark:text-white">
フォローユーザーの作品
{t("フォローユーザーの作品")}
</div>
</div>
<div className="mx-auto max-w-2xl px-4 sm:px-6 lg:max-w-7xl lg:px-8">
Expand Down Expand Up @@ -197,4 +200,10 @@ export default function App() {
<Footer/>
</div>
);
}
}

export const getStaticProps: GetStaticProps = async ({ locale }) => ({
props: {
...await serverSideTranslations(locale ?? 'ja', ['common', 'home']),
},
})
Empty file added public/locales/en/common.json
Empty file.
3 changes: 3 additions & 0 deletions public/locales/en/home.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"フォローユーザーの作品": "Works of users you are following"
}
Empty file added public/locales/ja/common.json
Empty file.
3 changes: 3 additions & 0 deletions public/locales/ja/home.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"フォローユーザーの作品": "フォローユーザーの作品"
}
Empty file added public/locales/zh/common.json
Empty file.
Empty file added public/locales/zh/home.json
Empty file.
71 changes: 69 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1794,7 +1794,7 @@
dependencies:
regenerator-runtime "^0.13.4"

"@babel/runtime@^7.11.2", "@babel/runtime@^7.8.4":
"@babel/runtime@^7.11.2", "@babel/runtime@^7.14.5", "@babel/runtime@^7.17.2", "@babel/runtime@^7.8.4":
version "7.20.1"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.20.1.tgz#1148bb33ab252b165a06698fde7576092a78b4a9"
integrity sha512-mrzLkl6U9YLF8qpqI7TB82PESyEGjm/0Ly91jG575eVxMMlb8fYfOXFZIJ8XfLrJZQbm7dlKry2bJmXBUEkdFg==
Expand Down Expand Up @@ -2247,6 +2247,14 @@
"@types/minimatch" "*"
"@types/node" "*"

"@types/hoist-non-react-statics@^3.3.1":
version "3.3.1"
resolved "https://registry.yarnpkg.com/@types/hoist-non-react-statics/-/hoist-non-react-statics-3.3.1.tgz#1124aafe5118cb591977aeb1ceaaed1070eb039f"
integrity sha512-iMIqiko6ooLrTh1joXodJK5X9xeEALT1kM5G3ZLhD3hszxBdIEd5C75U834D9mLcINgD4OyZf5uQXjkuYydWvA==
dependencies:
"@types/react" "*"
hoist-non-react-statics "^3.3.0"

"@types/json-schema@^7.0.5", "@types/json-schema@^7.0.8":
version "7.0.11"
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.11.tgz#d421b6c527a3037f7c84433fd2c4229e016863d3"
Expand Down Expand Up @@ -2282,6 +2290,15 @@
resolved "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.5.tgz"
integrity sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==

"@types/react@*":
version "18.0.25"
resolved "https://registry.yarnpkg.com/@types/react/-/react-18.0.25.tgz#8b1dcd7e56fe7315535a4af25435e0bb55c8ae44"
integrity sha512-xD6c0KDT4m7n9uD4ZHi02lzskaiqcBxf4zi+tXZY98a04wvc0hi/TcCPC2FOESZi51Nd7tlUeOJY8RofL799/g==
dependencies:
"@types/prop-types" "*"
"@types/scheduler" "*"
csstype "^3.0.2"

"@types/[email protected]":
version "18.0.21"
resolved "https://registry.npmjs.org/@types/react/-/react-18.0.21.tgz"
Expand Down Expand Up @@ -2911,6 +2928,11 @@ core-js-pure@^3.25.1:
resolved "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.25.5.tgz"
integrity sha512-oml3M22pHM+igfWHDfdLVq2ShWmjM2V4L+dQEBs0DWVIqEm9WHCwGAlZ6BmyBQGy5sFrJmcx+856D9lVKyGWYg==

core-js@^3:
version "3.26.1"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.26.1.tgz#7a9816dabd9ee846c1c0fe0e8fcad68f3709134e"
integrity sha512-21491RRQVzUn0GGM9Z1Jrpr6PNPxPi+Za8OM9q4tksTSnlbXXGKK1nXNg/QvwFYettXvSX6zWKCtHHfjN4puyA==

core-util-is@~1.0.0:
version "1.0.3"
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.3.tgz#a6042d3634c2b27e9328f837b965fac83808db85"
Expand Down Expand Up @@ -3841,7 +3863,7 @@ has@^1.0.3:
dependencies:
function-bind "^1.1.1"

hoist-non-react-statics@^3.3.2:
hoist-non-react-statics@^3.3.0, hoist-non-react-statics@^3.3.2:
version "3.3.2"
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz#ece0acaf71d62c2969c2ec59feff42a4b1a85b45"
integrity sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==
Expand All @@ -3855,6 +3877,13 @@ html-encoding-sniffer@^3.0.0:
dependencies:
whatwg-encoding "^2.0.0"

html-parse-stringify@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/html-parse-stringify/-/html-parse-stringify-3.0.1.tgz#dfc1017347ce9f77c8141a507f233040c59c55d2"
integrity sha512-KknJ50kTInJ7qIScF3jeaFRpMpE8/lfiTdzf/twXyPBLAGrLRTmkz3AdTnKeh40X8k9L2fdYwEp/42WGXIRGcg==
dependencies:
void-elements "3.1.0"

http-proxy-agent@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/http-proxy-agent/-/http-proxy-agent-5.0.0.tgz#5129800203520d434f142bc78ff3c170800f2b43"
Expand All @@ -3872,6 +3901,18 @@ https-proxy-agent@^5.0.1:
agent-base "6"
debug "4"

i18next-fs-backend@^1.1.5:
version "1.2.0"
resolved "https://registry.yarnpkg.com/i18next-fs-backend/-/i18next-fs-backend-1.2.0.tgz#c498c68c8e6a8ae5ed59bea5e5392a11991de696"
integrity sha512-pUx3AcgXCbur0jpFA7U67Z2RJflAcIi698Y8VL+phdOqUchahxriV3Cs+M6UkPNQSS/zPEzWLfdJ8EgjB7HVxg==

i18next@^21.9.1:
version "21.10.0"
resolved "https://registry.yarnpkg.com/i18next/-/i18next-21.10.0.tgz#85429af55fdca4858345d0e16b584ec29520197d"
integrity sha512-YeuIBmFsGjUfO3qBmMOc0rQaun4mIpGKET5WDwvu8lU7gvwpcariZLNtL0Fzj+zazcHUrlXHiptcFhBMFaxzfg==
dependencies:
"@babel/runtime" "^7.17.2"

[email protected]:
version "0.6.3"
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.6.3.tgz#a52f80bf38da1952eb5c681790719871a1a72501"
Expand Down Expand Up @@ -4600,6 +4641,19 @@ next-compose-plugins@^2.2.1:
resolved "https://registry.yarnpkg.com/next-compose-plugins/-/next-compose-plugins-2.2.1.tgz#020fc53f275a7e719d62521bef4300fbb6fde5ab"
integrity sha512-OjJ+fV15FXO2uQXQagLD4C0abYErBjyjE0I0FHpOEIB8upw0hg1ldFP6cqHTJBH1cZqy96OeR3u1dJ+Ez2D4Bg==

next-i18next@^12.1.0:
version "12.1.0"
resolved "https://registry.yarnpkg.com/next-i18next/-/next-i18next-12.1.0.tgz#70926fbe966bc4750d2f68573307bfe36eadba46"
integrity sha512-rhos/PVULmZPdC0jpec2MDBQMXdGZ3+Mbh/tZfrDtjgnVN3ucdq7k8BlwsJNww6FnqC8AC31n6dSYuqVzYsGsw==
dependencies:
"@babel/runtime" "^7.18.9"
"@types/hoist-non-react-statics" "^3.3.1"
core-js "^3"
hoist-non-react-statics "^3.3.2"
i18next "^21.9.1"
i18next-fs-backend "^1.1.5"
react-i18next "^11.18.4"

next-pwa@^5.6.0:
version "5.6.0"
resolved "https://registry.yarnpkg.com/next-pwa/-/next-pwa-5.6.0.tgz#f7b1960c4fdd7be4253eb9b41b612ac773392bf4"
Expand Down Expand Up @@ -5114,6 +5168,14 @@ react-dom@^18.2.0:
loose-envify "^1.1.0"
scheduler "^0.23.0"

react-i18next@^11.18.4:
version "11.18.6"
resolved "https://registry.yarnpkg.com/react-i18next/-/react-i18next-11.18.6.tgz#e159c2960c718c1314f1e8fcaa282d1c8b167887"
integrity sha512-yHb2F9BiT0lqoQDt8loZ5gWP331GwctHz9tYQ8A2EIEUu+CcEdjBLQWli1USG3RdWQt3W+jqQLg/d4rrQR96LA==
dependencies:
"@babel/runtime" "^7.14.5"
html-parse-stringify "^3.0.1"

react-is@^16.13.1, react-is@^16.7.0:
version "16.13.1"
resolved "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz"
Expand Down Expand Up @@ -5951,6 +6013,11 @@ uuid@^9.0.0:
resolved "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz"
integrity sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==

[email protected]:
version "3.1.0"
resolved "https://registry.yarnpkg.com/void-elements/-/void-elements-3.1.0.tgz#614f7fbf8d801f0bb5f0661f5b2f5785750e4f09"
integrity sha512-Dhxzh5HZuiHQhbvTW9AMetFfBHDMYpo23Uo9btPXgdYP+3T5S+p+jgNy7spra+veYhBP2dCSgxR/i2Y02h5/6w==

w3c-xmlserializer@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/w3c-xmlserializer/-/w3c-xmlserializer-3.0.0.tgz#06cdc3eefb7e4d0b20a560a5a3aeb0d2d9a65923"
Expand Down

1 comment on commit 02984d5

@vercel
Copy link

@vercel vercel bot commented on 02984d5 Nov 16, 2022

Choose a reason for hiding this comment

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

Please sign in to comment.