* feature eventType specific language or bookingPage language * chore * fix type checks * chore * chore: remove log * improvement: this updates in DatePicker is not required with context provider method * added e2e tests for InterfaceLanguage feature * corrected prev merge conflict issues * update to align with hooks usage pattern * chore * unrelated auto-formatting changes * unrelated auto-formatting changes * unrelated auto-formatting changes * update to affect interfaceLanguage on success page * undone prettier changes * update test for success page translation * chore * return null from memo * fix typecheck error due to atom imports in useLocale * set default interfaceLanguage as null * updated to use null instead of constant * enhancements * fix latest unit test, use prop instead of useSession hook * fix build issue * chore * fix atom build issue * fix unit test with reqd mock * update to use server i18n rendering * nit * Move import localeOptions to EventSetupTabWebWrapper * make sure we only display interface language option in web app * using customI18nProvider --------- Co-authored-by: amrit <iamamrit27@gmail.com> Co-authored-by: Tushar Bhatt <95581504+TusharBhatt1@users.noreply.github.com> Co-authored-by: Tushar <tusharbhatt0135@gmail.com> Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com> Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: Ryukemeister <sahalrajiv6900@gmail.com> Co-authored-by: Rajiv Sahal <sahalrajiv-extc@atharvacoe.ac.in> Co-authored-by: Benny Joo <sldisek783@gmail.com>
34 lines
710 B
TypeScript
34 lines
710 B
TypeScript
"use client";
|
|
|
|
import { createContext, useMemo } from "react";
|
|
import type { ReactNode } from "react";
|
|
|
|
type CustomI18nContextType = {
|
|
translations: Record<string, string>;
|
|
ns: string;
|
|
locale: string;
|
|
};
|
|
|
|
export const CustomI18nContext = createContext<CustomI18nContextType | null>(null);
|
|
|
|
export function CustomI18nProvider({
|
|
children,
|
|
translations,
|
|
locale,
|
|
ns,
|
|
}: CustomI18nContextType & {
|
|
children: ReactNode;
|
|
}) {
|
|
// Memoize the value to prevent re-renders unless the data changes
|
|
const value = useMemo(
|
|
() => ({
|
|
translations,
|
|
locale,
|
|
ns,
|
|
}),
|
|
[locale, ns]
|
|
);
|
|
|
|
return <CustomI18nContext.Provider value={value}>{children}</CustomI18nContext.Provider>;
|
|
}
|