mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-07-16 00:14:21 -05:00
Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Kalle <38327916+Sendouc@users.noreply.github.com>
16 lines
495 B
TypeScript
16 lines
495 B
TypeScript
import * as React from "react";
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
/**
|
|
* Detect when the locale returned by the root route loader changes and call
|
|
* `i18n.changeLanguage` with the new locale so translations load automatically.
|
|
*
|
|
* Vendored from remix-i18next (removed in v8).
|
|
*/
|
|
export function useChangeLanguage(locale: string) {
|
|
const { i18n } = useTranslation();
|
|
React.useEffect(() => {
|
|
if (i18n.language !== locale) i18n.changeLanguage(locale);
|
|
}, [locale, i18n]);
|
|
}
|