Open czw333221 opened 4 months ago
Directory structure: src/ ├── app/ │ └──actions.ts next-i18next.config.js next.config.js
//next-i18next.config.js /**
//next.config.js const { withStoreConfig } = require("./store-config") const store = require("./store.config.json")
/* @type {import('next').NextConfig} / const { i18n } = require('./next-i18next.config');
/**
console.log("next.config.js", JSON.stringify(module.exports, null, 2))
module.exports = nextConfig
//actions.ts "use server"
import { revalidateTag } from "next/cache" import { cookies } from "next/headers" import { redirect } from "next/navigation"
import { getRegion, updateCart } from "@lib/data"
@param countryCode */ export async function updateRegion(countryCode: string, currentPath: string) { const cartId = cookies().get("_medusa_cart_id")?.value const region = await getRegion(countryCode)
if (!region) { return null }
try { if (cartId) { await updateCart(cartId, { region_id: region.id }) revalidateTag("cart") }
revalidateTag("regions") revalidateTag("products") } catch (e) { return "Error updating region" } console.log("1111") redirect(/${countryCode}${currentPath}) }
/${countryCode}${currentPath}
export async function resetOnboardingState(orderId: string) { cookies().set("_medusa_onboarding", "false", { maxAge: -1 }) redirect(http://localhost:7001/a/orders/${orderId}) }
http://localhost:7001/a/orders/${orderId}
The expected result should be yarn dev running and automatically jumping to http://localhost:8000/zh after opening http://localhost:8000
Next.js has it's own language detection... beside that, I don't know exactly what you mean... Please do not just paste code snippets but create a minimal reproducible example repository
Directory structure: src/ ├── app/ │ └──actions.ts next-i18next.config.js next.config.js
//next-i18next.config.js /**
//next.config.js const { withStoreConfig } = require("./store-config") const store = require("./store.config.json")
/* @type {import('next').NextConfig} / const { i18n } = require('./next-i18next.config');
/**
console.log("next.config.js", JSON.stringify(module.exports, null, 2))
module.exports = nextConfig
//actions.ts "use server"
import { revalidateTag } from "next/cache" import { cookies } from "next/headers" import { redirect } from "next/navigation"
import { getRegion, updateCart } from "@lib/data"
/**
@param countryCode */ export async function updateRegion(countryCode: string, currentPath: string) { const cartId = cookies().get("_medusa_cart_id")?.value const region = await getRegion(countryCode)
if (!region) { return null }
try { if (cartId) { await updateCart(cartId, { region_id: region.id }) revalidateTag("cart") }
revalidateTag("regions") revalidateTag("products") } catch (e) { return "Error updating region" } console.log("1111") redirect(
/${countryCode}${currentPath}
) }export async function resetOnboardingState(orderId: string) { cookies().set("_medusa_onboarding", "false", { maxAge: -1 }) redirect(
http://localhost:7001/a/orders/${orderId}
) }The expected result should be yarn dev running and automatically jumping to http://localhost:8000/zh after opening http://localhost:8000