1
Fork 0
mirror of https://github.com/Steffo99/festa.git synced 2024-12-22 14:44:21 +00:00

Configure i18n

This commit is contained in:
Steffo 2022-05-25 16:20:22 +02:00
parent 6ce9bfe755
commit 5a4e2e8e1a
Signed by: steffo
GPG key ID: 6965406171929D01
11 changed files with 118 additions and 20 deletions

View file

@ -5,8 +5,6 @@ import { useDefinedContext } from "../hooks/useDefinedContext";
export function Postcard() {
const [postcard, _] = useDefinedContext(PostcardContext)
console.log(postcard)
return (
<img
className="postcard"

9
next-i18next.config.js Normal file
View file

@ -0,0 +1,9 @@
module.exports = {
i18n: {
defaultLocale: "it-IT",
locales: [
"it-IT",
],
localePath: path.resolve('./public/locales'),
}
}

View file

@ -1,6 +1,9 @@
import i18n from "./next-i18next.config"
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
i18n,
}
module.exports = nextConfig

View file

@ -11,6 +11,7 @@
"dependencies": {
"@prisma/client": "3.14.0",
"next": "12.1.6",
"next-i18next": "^11.0.0",
"prisma": "^3.14.0",
"react": "18.1.0",
"react-dom": "18.1.0",

View file

@ -11,8 +11,9 @@ import defaultPostcard from "../images/adi-goldstein-Hli3R6LKibo-unsplash.jpg"
import { Postcard } from '../components/Postcard'
import { PostcardContext } from '../contexts/postcard'
import { StaticImageData } from 'next/image'
import { appWithTranslation } from 'next-i18next'
const App = ({ Component, pageProps }: AppProps): React.ReactNode => {
const App = ({ Component, pageProps }: AppProps): JSX.Element => {
const loginHook = useState<Telegram.LoginData | null>(null)
const postcardHook = useState<string | StaticImageData>(defaultPostcard)
@ -20,11 +21,10 @@ const App = ({ Component, pageProps }: AppProps): React.ReactNode => {
<PostcardContext.Provider value={postcardHook}>
<LoginContext.Provider value={loginHook}>
<Postcard/>
<Navbar/>
<Component {...pageProps} />
</LoginContext.Provider>
</PostcardContext.Provider>
)
}
export default App
export default appWithTranslation(App)

View file

@ -1,9 +1,24 @@
import type { NextPage } from 'next'
import type { NextPage, NextPageContext } from 'next'
import { useTranslation } from 'next-i18next'
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
export async function getStaticProps(context: NextPageContext) {
return {props: {
...(await serverSideTranslations(context.locale ?? "it-IT", ["common"]))
}}
}
const Page: NextPage = () => {
const {t} = useTranslation("common")
return (
<div>
<h1>
{t("title")}
</h1>
<p>
{t("description")}
</p>
</div>
)
}

View file

@ -0,0 +1,4 @@
{
"title": "Festa",
"description": "Sito per organizzare eventi"
}

View file

@ -1,6 +1,7 @@
html, body {
padding: 0;
margin: 0;
font-family: sans-serif;
}
* {

View file

@ -25,15 +25,3 @@ nav h1 {
justify-content: space-between;
align-items: center;
}
@media (prefers-color-scheme: light) {
nav {
background-color: rgba(255, 255, 255, 0.2);
}
}
@media (prefers-color-scheme: dark) {
nav {
background-color: rgba(0, 0, 0, 0.2);
}
}

View file

@ -7,6 +7,7 @@
z-index: -1;
user-select: none;
pointer-events: none;
}
@media (prefers-color-scheme: light) {

View file

@ -17,6 +17,13 @@
dependencies:
regenerator-runtime "^0.13.4"
"@babel/runtime@^7.13.17", "@babel/runtime@^7.14.5", "@babel/runtime@^7.17.2":
version "7.18.2"
resolved "https://registry.npmjs.org/@babel/runtime/-/runtime-7.18.2.tgz#674575748fa99cf03694e77fc00de8e5117b42a0"
integrity sha512-mTV1PibQHr88R1p4nH/uhR/TJ0mXGEgKTx6Mnd1cn/DSA9r8fqbd+d31xujI2C1pRWtxjy+HAcmtB+MEcF4VNg==
dependencies:
regenerator-runtime "^0.13.4"
"@eslint/eslintrc@^1.2.3":
version "1.2.3"
resolved "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.2.3.tgz#fcaa2bcef39e13d6e9e7f6271f4cc7cae1174886"
@ -161,6 +168,14 @@
resolved "https://registry.npmjs.org/@rushstack/eslint-patch/-/eslint-patch-1.1.3.tgz#6801033be7ff87a6b7cadaf5b337c9f366a3c4b0"
integrity sha512-WiBSI6JBIhC6LRIsB2Kwh8DsGTlbBU+mLRxJmAe3LjHTdkDpwIbEOZgoXBbZilk/vlfjK8i6nKRAvIRn1XaIMw==
"@types/hoist-non-react-statics@^3.3.1":
version "3.3.1"
resolved "https://registry.npmjs.org/@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/json5@^0.0.29":
version "0.0.29"
resolved "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee"
@ -405,6 +420,11 @@ core-js-pure@^3.20.2:
resolved "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.22.5.tgz#bdee0ed2f9b78f2862cda4338a07b13a49b6c9a9"
integrity sha512-8xo9R00iYD7TcV7OrC98GwxiUEAabVWO3dix+uyWjnYrx9fyASLlIX+f/3p5dW5qByaP2bcZ8X/T47s55et/tA==
core-js@^3:
version "3.22.7"
resolved "https://registry.npmjs.org/core-js/-/core-js-3.22.7.tgz#8d6c37f630f6139b8732d10f2c114c3f1d00024f"
integrity sha512-Jt8SReuDKVNZnZEzyEQT5eK6T2RRCXkfTq7Lo09kpm+fHjgGewSbNjV+Wt4yZMhPDdzz2x1ulI5z/w4nxpBseg==
cross-spawn@^7.0.2:
version "7.0.3"
resolved "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
@ -944,6 +964,37 @@ has@^1.0.3:
dependencies:
function-bind "^1.1.1"
hoist-non-react-statics@^3.2.0, hoist-non-react-statics@^3.3.0:
version "3.3.2"
resolved "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz#ece0acaf71d62c2969c2ec59feff42a4b1a85b45"
integrity sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==
dependencies:
react-is "^16.7.0"
html-escaper@^2.0.2:
version "2.0.2"
resolved "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz#dfd60027da36a36dfcbe236262c00a5822681453"
integrity sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==
html-parse-stringify@^3.0.1:
version "3.0.1"
resolved "https://registry.npmjs.org/html-parse-stringify/-/html-parse-stringify-3.0.1.tgz#dfc1017347ce9f77c8141a507f233040c59c55d2"
integrity sha512-KknJ50kTInJ7qIScF3jeaFRpMpE8/lfiTdzf/twXyPBLAGrLRTmkz3AdTnKeh40X8k9L2fdYwEp/42WGXIRGcg==
dependencies:
void-elements "3.1.0"
i18next-fs-backend@^1.1.4:
version "1.1.4"
resolved "https://registry.npmjs.org/i18next-fs-backend/-/i18next-fs-backend-1.1.4.tgz#d0e9b9ed2fa7a0f11002d82b9fa69c3c3d6482da"
integrity sha512-/MfAGMP0jHonV966uFf9PkWWuDjPYLIcsipnSO3NxpNtAgRUKLTwvm85fEmsF6hGeu0zbZiCQ3W74jwO6K9uXA==
i18next@^21.6.14:
version "21.8.4"
resolved "https://registry.npmjs.org/i18next/-/i18next-21.8.4.tgz#646e23065752036b38d9fda8898c18139b9e8ebe"
integrity sha512-b3LQ5n9V1juu8UItb5x1QTI4OTvNqsNs/wetwQlBvfijEqks+N5HKMKSoevf8w0/RGUrDQ7g4cvVzF8WBp9pUw==
dependencies:
"@babel/runtime" "^7.17.2"
ignore@^5.2.0:
version "5.2.0"
resolved "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz#6d3bac8fa7fe0d45d9f9be7bac2fc279577e345a"
@ -1222,6 +1273,19 @@ natural-compare@^1.4.0:
resolved "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"
integrity sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=
next-i18next@^11.0.0:
version "11.0.0"
resolved "https://registry.npmjs.org/next-i18next/-/next-i18next-11.0.0.tgz#2857d13c58a5ed976fe57c44286f1520b07f7c96"
integrity sha512-phxbQiZGSJTTBE2FI4+BnqFZl88AI2V+6MrEQnT9aPFAXq/fATQ/F0pOUM3J7kU4nEeCfn3hjISq+ygGHlEz0g==
dependencies:
"@babel/runtime" "^7.13.17"
"@types/hoist-non-react-statics" "^3.3.1"
core-js "^3"
hoist-non-react-statics "^3.2.0"
i18next "^21.6.14"
i18next-fs-backend "^1.1.4"
react-i18next "^11.16.2"
next@12.1.6:
version "12.1.6"
resolved "https://registry.npmjs.org/next/-/next-12.1.6.tgz#eb205e64af1998651f96f9df44556d47d8bbc533"
@ -1433,7 +1497,16 @@ react-dom@18.1.0:
loose-envify "^1.1.0"
scheduler "^0.22.0"
react-is@^16.13.1:
react-i18next@^11.16.2:
version "11.16.9"
resolved "https://registry.npmjs.org/react-i18next/-/react-i18next-11.16.9.tgz#890cdac0c49120e075d6c520b43dbad3f91bd2df"
integrity sha512-euXxWvcEAvsY7ZVkwx9ztCq4butqtsGHEkpkuo0RMj8Ru09IF9o2KxCyN+zyv51Nr0aBh/elaTIiR6fMb8YfVg==
dependencies:
"@babel/runtime" "^7.14.5"
html-escaper "^2.0.2"
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#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==
@ -1710,6 +1783,11 @@ v8-compile-cache@^2.0.3:
resolved "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz#2de19618c66dc247dcfb6f99338035d8245a2cee"
integrity sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==
void-elements@3.1.0:
version "3.1.0"
resolved "https://registry.npmjs.org/void-elements/-/void-elements-3.1.0.tgz#614f7fbf8d801f0bb5f0661f5b2f5785750e4f09"
integrity sha1-YU9/v42AHwu18GYfWy9XhXUOTwk=
which-boxed-primitive@^1.0.2:
version "1.0.2"
resolved "https://registry.npmjs.org/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz#13757bc89b209b049fe5d86430e21cf40a89a8e6"