feat(routing): shorten language URL prefixes to ISO codes with legacy redirects
All checks were successful
Deploy to Frontend Servers / deploy (push) Successful in 31s

Rename the localized URL prefixes from full English names to short
ISO-style codes:
  /chinese    -> /cn
  /japanese   -> /ja
  /korean     -> /ko
  /vietnamese -> /vi
  /indonesian -> /id
  /malay      -> /ms

Add legacyLanguageRedirects mapping and a LegacyLangRedirect component
in App.tsx so links shared on WeChat (and elsewhere) that still use the
long-form paths keep landing on the right page. The redirect preserves
the sub-path, query string, and hash, e.g.
  /malay/browse?post=42#x -> /ms/browse?post=42#x

Also refresh doc-comment examples in i18n.tsx, FigmaBanner.tsx,
PublicLayout.tsx, and useLocalizedPath.ts so future readers see the new
prefixes.
This commit is contained in:
TerryM
2026-06-04 12:01:38 +08:00
parent 53614189ce
commit 1b52a6d93d
8 changed files with 122 additions and 32 deletions

View File

@@ -5,7 +5,7 @@ import { localizePath } from "./languageRoutes";
/**
* Returns a stable `(path) => localized path` function bound to the current
* UI language. Use this anywhere a `<Link to>` or `navigate()` target needs to
* preserve the active language prefix (e.g. `/malay/browse`).
* preserve the active language prefix (e.g. `/ms/browse`).
*/
export function useLocalizedPath() {
const { lang } = useI18n();