Refactors useLocale (#908)
* Removes unused component * Refactors useLocale We don't need to pass the locale prop everywhere * Fixes syntax error * Adds warning for missing localeProps * Simplify i18n utils * Update components/I18nLanguageHandler.tsx Co-authored-by: Mihai C <[email protected]> * Type fixes Co-authored-by: Mihai C <[email protected]>
This commit is contained in:
1 parent
7dd6fdde7a
commit
cfd70172f0
35 files changed
+366
-440
No files matched your search
+1
-10
@@ -1,19 +1,10 @@
|
||||
import { useTranslation } from "next-i18next";
|
||||
|
||||
type LocaleProp = {
|
||||
localeProp: string;
|
||||
};
|
||||
|
||||
export const useLocale = (props: LocaleProp) => {
|
||||
export const useLocale = () => {
|
||||
const { i18n, t } = useTranslation("common");
|
||||
|
||||
if (i18n.language !== props.localeProp) {
|
||||
i18n.changeLanguage(props.localeProp);
|
||||
}
|
||||
|
||||
return {
|
||||
i18n,
|
||||
locale: props.localeProp,
|
||||
t,
|
||||
};
|
||||
};
|
||||
Reference in new issue
Block a user