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.
14 lines
489 B
TypeScript
14 lines
489 B
TypeScript
import { useCallback } from "react";
|
|
import { useI18n } from "./i18n";
|
|
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. `/ms/browse`).
|
|
*/
|
|
export function useLocalizedPath() {
|
|
const { lang } = useI18n();
|
|
return useCallback((path: string) => localizePath(path, lang), [lang]);
|
|
}
|