2026-06-01 16:35:40 +08:00
|
|
|
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
|
2026-06-04 12:01:38 +08:00
|
|
|
* preserve the active language prefix (e.g. `/ms/browse`).
|
2026-06-01 16:35:40 +08:00
|
|
|
*/
|
|
|
|
|
export function useLocalizedPath() {
|
|
|
|
|
const { lang } = useI18n();
|
|
|
|
|
return useCallback((path: string) => localizePath(path, lang), [lang]);
|
|
|
|
|
}
|