yuxinqi
Has anyone ever used tRPC (with SSR) and i18n?
with next-i18next,it work for me
// /src/pages/_app.tsx
import nextI18NextConfig from "../../next-i18next.config.js";
const prod = process.env.NODE_ENV === "production";
MyApp.getInitialProps = async ({ ctx: { locale } }) => {
return {
pageProps: {
...(await serverSideTranslations(
locale || nextI18NextConfig.i18n.defaultLocale,
["common"],
{ ...nextI18NextConfig, reloadOnPrerender: !prod }
)),
},
};
};
export default trpc.withTRPC(appWithTranslation(MyApp));
// /src/pages/_app.tsx
import nextI18NextConfig from "../../next-i18next.config.js";
const prod = process.env.NODE_ENV === "production";
MyApp.getInitialProps = async ({ ctx: { locale } }) => {
return {
pageProps: {
...(await serverSideTranslations(
locale || nextI18NextConfig.i18n.defaultLocale,
["common"],
{ ...nextI18NextConfig, reloadOnPrerender: !prod }
)),
},
};
};
export default trpc.withTRPC(appWithTranslation(MyApp));
// /next.config.mjs
import i18nConfig from "./next-i18next.config.js";
const nextConfig = {
i18n: i18nConfig.i18n,
webpack: (config, { isServer }) => {
// Fixes npm packages that depend on `fs` module
if (!isServer) {
config.resolve.fallback.fs = false;
}
return config;
},
};
export default nextConfig;
// /next.config.mjs
import i18nConfig from "./next-i18next.config.js";
const nextConfig = {
i18n: i18nConfig.i18n,
webpack: (config, { isServer }) => {
// Fixes npm packages that depend on `fs` module
if (!isServer) {
config.resolve.fallback.fs = false;
}
return config;
},
};
export default nextConfig;
35 replies