Skip to content

Commit

Permalink
feat(frontend): setting next-i18next
Browse files Browse the repository at this point in the history
  • Loading branch information
gangjun06 committed Dec 9, 2022
1 parent d516b29 commit 96ebe3e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
34 changes: 34 additions & 0 deletions frontend/next-i18next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// @ts-check

/**
* @type {import('next-i18next').UserConfig}
*/
module.exports = {
// https://www.i18next.com/overview/configuration-options#logging
debug: process.env.NODE_ENV === "development",
i18n: {
defaultLocale: "en",
locales: ["en", "de"],
},
/** To avoid issues when deploying to some paas (vercel...) */
// localePath:
// typeof window === "undefined"
// ? require("path").resolve("./public/locales")
// : "/locales",
localePath: (locale, namespace, missing) => {
const data = JSON.parse(
require("path").resolve(`./public/locales/${locale}.json`)
);
return data.default[namespace];
},

reloadOnPrerender: process.env.NODE_ENV === "development",

/**
* @link https://github.com/i18next/next-i18next#6-advanced-configuration
*/
// saveMissing: false,
// strictMode: true,
// serializeConfig: false,
// react: { useSuspense: false }
};
7 changes: 4 additions & 3 deletions frontend/next.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// next.config.js
const { i18n } = require("./next-i18next.config.js");
const nextTranslate = require("next-translate");

const ContentSecurityPolicy = `
Expand Down Expand Up @@ -50,7 +50,7 @@ const securityHeaders = [
},
];

module.exports = nextTranslate({
module.exports = {
output: "standalone",
async headers() {
return [
Expand All @@ -64,4 +64,5 @@ module.exports = nextTranslate({
webpack: (config, { isServer, webpack }) => {
return config;
},
});
i18n,
};

0 comments on commit 96ebe3e

Please sign in to comment.