mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 11:39:50 +02:00
feat: some more localized links
This commit is contained in:
1 parent
8203db3dc2
commit
e0daf85561
19 files changed
+182
-81
No files matched your search
@@ -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 };
|
||||
}
|
||||
Reference in new issue
Block a user