import { useCallback } from "react";
import { useHistory, useRouteMatch } from "react-router-dom";
export const useMatchLang = () => {
    const match = useRouteMatch("/:lang/(.*)");
    const simpleMatch = useRouteMatch("/:lang");
    return match?.params.lang ?? simpleMatch?.params.lang ?? "en";
};
export const useLink = () => {
    const history = useHistory();
    const lang = useMatchLang();
    return useCallback((path) => {
        history.push(`/${lang}/${path}`);
        window.scrollTo(0, 0);
    }, [lang]);
};
export const useLang = () => {
    const history = useHistory();
    const match = useRouteMatch("/:lang/(.*)");
    const path = match?.params[0] ?? "";
    return useCallback((lang) => {
        history.push(`/${lang}/${path}`);
    }, [path]);
};
/** @deprecated duplicate of useMatchLang */
export const useGetLang = () => {
    const lang = useMatchLang();
    return lang;
};
//# sourceMappingURL=locale.js.map