feat: some more localized links

This commit is contained in:
tresabhi committed 2024-12-27 14:01:59 -06:00
1 parent 8203db3dc2
commit e0daf85561
19 files changed
+182 -81

No files matched your search

+28
View File
@@ -0,0 +1,28 @@
import { createContext, useContext, type ReactNode } from 'react';
const LocaleContext = createContext<{ locale: string | undefined } | null>(
null,
);
interface LocaleProviderProps {
locale: string | undefined;
children: ReactNode;
}
export function LocaleProvider({ locale, children }: LocaleProviderProps) {
return (
<LocaleContext.Provider value={{ locale }}>
{children}
</LocaleContext.Provider>
);
}
export function useLocale() {
const context = useContext(LocaleContext);
if (!context) {
throw new Error('useLocale must be used within a LocaleProvider');
}
return { locale: context.locale };
}