- Wrap getDictionary with React cache to prevent redundant JSON parsing on the server - Create MotionProvider to globally initialize framer-motion LazyMotion with domAnimation - Replace standard 'motion' imports with 'm' across all animated client components (HomeClient, Navbar, GaleriClient, SSSClient, card, text-reveal) to drastically reduce First Load JS size
18 lines
495 B
TypeScript
18 lines
495 B
TypeScript
import 'server-only';
|
|
import { cache } from 'react';
|
|
|
|
const dictionaries = {
|
|
en: () => import('../dictionaries/en.json').then((module) => module.default),
|
|
tr: () => import('../dictionaries/tr.json').then((module) => module.default),
|
|
};
|
|
|
|
export type Locale = keyof typeof dictionaries;
|
|
export const i18n = {
|
|
defaultLocale: 'tr',
|
|
locales: ['tr', 'en'],
|
|
} as const;
|
|
|
|
export const getDictionary = cache(async (locale: Locale) => {
|
|
return dictionaries[locale]?.() ?? dictionaries.tr();
|
|
});
|