feat: add i18n support and add Chinese (#372)

* feat: add i18n support and add Chinese

* fix: resolve conflicts

* Update en.json with cancle settings

* Update zh.json with settngs cancle

---------

Co-authored-by: johnny0120 <15564476+johnny0120@users.noreply.github.com>
Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
Co-authored-by: Willem Jiang <143703838+willem-bd@users.noreply.github.com>
This commit is contained in:
johnny0120
2025-07-12 15:18:28 +08:00
committed by GitHub
parent 136f7eaa4e
commit e1187d7d02
31 changed files with 917 additions and 266 deletions

23
web/src/i18n.ts Normal file
View File

@@ -0,0 +1,23 @@
// Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
// SPDX-License-Identifier: MIT
import { cookies } from "next/headers";
import { getRequestConfig } from "next-intl/server";
// Can be imported from a shared config
const locales: Array<string> = ["zh", "en"];
export default getRequestConfig(async () => {
// Get locale from cookie
const cookieStore = await cookies();
const cookieLocale = cookieStore.get("NEXT_LOCALE")?.value;
// Validate that the incoming `locale` parameter is valid
const locale =
cookieLocale && locales.includes(cookieLocale) ? cookieLocale : "en";
return {
messages: (await import(`../messages/${locale}.json`)).default,
locale,
};
});