sendou.ink/app/modules/i18n/useChangeLanguage.ts
dependabot[bot] 938d7efd96
build(deps): bump remix-i18next from 7.5.0 to 8.0.0 (#3215)
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>
2026-07-10 17:40:24 +03:00

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]);
}