release: v0.12.0 (#520)

Forty-one commits since v0.11.0. See CHANGELOG.md for the full list and the upgrade notes.
This commit is contained in:
Ralksta
2026-08-23 23:18:14 +02:00
committed by GitHub
parent 2f546f440d
commit 10ec68f493
119 changed files with 6888 additions and 758 deletions

View File

@@ -0,0 +1,29 @@
'use client';
/**
* Carries the resolved locale to client components.
*
* Only the locale string crosses the server/client boundary — dictionaries
* contain functions and would not serialise, so `useDictionary()` looks the
* object up on the client instead of receiving it as a prop.
*/
import { createContext, useContext, useMemo } from 'react';
import { DEFAULT_LOCALE, getDictionary, type Dictionary, type Locale } from '@/lib/i18n';
const LocaleContext = createContext<Locale>(DEFAULT_LOCALE);
export function I18nProvider({ locale, children }: { locale: Locale; children: React.ReactNode }) {
return <LocaleContext.Provider value={locale}>{children}</LocaleContext.Provider>;
}
/** Resolved locale — `DEFAULT_LOCALE` outside a provider. */
export function useLocale(): Locale {
return useContext(LocaleContext);
}
/** Dictionary for the current locale. */
export function useDictionary(): Dictionary {
const locale = useLocale();
return useMemo(() => getDictionary(locale), [locale]);
}