From bfc09c5d8582ef9aa131038273532b4ea925d963 Mon Sep 17 00:00:00 2001 From: Alex van Andel Date: Mon, 6 Dec 2021 00:51:02 +0100 Subject: [PATCH] i18n prototype --- next-env.d.ts | 1 - next.config.js | 7 + package.json | 4 +- pages/[locale]/index.tsx | 5 - pages/{[locale] => }/[user].tsx | 2 + pages/{[locale] => }/[user]/[type].tsx | 0 pages/{[locale] => }/[user]/book.tsx | 0 pages/_middleware.ts | 33 ++-- public/static/locales/default/common.json | 1 + yarn.lock | 175 +++++++++++----------- 10 files changed, 111 insertions(+), 117 deletions(-) delete mode 100644 pages/[locale]/index.tsx rename pages/{[locale] => }/[user].tsx (99%) rename pages/{[locale] => }/[user]/[type].tsx (100%) rename pages/{[locale] => }/[user]/book.tsx (100%) create mode 100644 public/static/locales/default/common.json diff --git a/next-env.d.ts b/next-env.d.ts index 9bc3dd46b9..4f11a03dc6 100644 --- a/next-env.d.ts +++ b/next-env.d.ts @@ -1,5 +1,4 @@ /// -/// /// // NOTE: This file should not be edited diff --git a/next.config.js b/next.config.js index 8297fc508c..c0ea5df042 100644 --- a/next.config.js +++ b/next.config.js @@ -1,5 +1,6 @@ /* eslint-disable @typescript-eslint/no-var-requires */ const withTM = require("@vercel/edge-functions-ui/transpile")(["react-timezone-select"]); +const path = require("path"); // So we can test deploy previews preview if (process.env.VERCEL_URL && !process.env.BASE_URL) { @@ -61,6 +62,12 @@ module.exports = () => plugins.reduce((acc, next) => next(acc), { typescript: { ignoreBuildErrors: true, }, + i18n: { + defaultLocale: "default", + localeDetection: false, + locales: ["default", "en", "fr", "it", "ru", "es", "de", "pt", "ro", "nl", "pt-BR", "es-419", "ko", "ja"], + }, + localePath: path.resolve("./public/static/locales"), webpack: (config) => { config.resolve.fallback = { ...config.resolve.fallback, // if you miss it, all the other options in fallback, specified diff --git a/package.json b/package.json index c0079dafd2..47a123e6dc 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "jimp": "^0.16.1", "lodash": "^4.17.21", "micro": "^9.3.4", - "next": "^12.0.4", + "next": "v12.0.8-canary.0", "next-auth": "^3.29.0", "next-i18next": "^8.9.0", "next-seo": "^4.26.0", @@ -91,8 +91,8 @@ "react-use-intercom": "1.4.0", "short-uuid": "^4.2.0", "stripe": "^8.191.0", - "tsdav": "^1.1.5", "superjson": "1.8.0", + "tsdav": "^1.1.5", "tslog": "^3.2.1", "uuid": "^8.3.2", "zod": "^3.8.2" diff --git a/pages/[locale]/index.tsx b/pages/[locale]/index.tsx deleted file mode 100644 index 2ac43b62d7..0000000000 --- a/pages/[locale]/index.tsx +++ /dev/null @@ -1,5 +0,0 @@ -/** - * Needed for `_middleware.ts` to work properly - * We can decide later what should happen when a user tries to access a locale root. - */ -export default () => null; diff --git a/pages/[locale]/[user].tsx b/pages/[user].tsx similarity index 99% rename from pages/[locale]/[user].tsx rename to pages/[user].tsx index 0f91b7085f..53498053c3 100644 --- a/pages/[locale]/[user].tsx +++ b/pages/[user].tsx @@ -44,6 +44,8 @@ export default function User(props: inferSSRProps) { const { user, eventTypes } = query.data; const nameOrUsername = user.name || user.username || ""; + console.log(router.locale); + return ( <>