import 'server-only';
import { cookies } from 'next/headers';
import en from '../messages/en.json';
import ar from '../messages/ar.json';

const translations = {
  en: JSON.parse(JSON.stringify(en)),
  ar: JSON.parse(JSON.stringify(ar))
};

export async function getCurrentLocale() {
  const cookieStore = await cookies();
  return cookieStore.get('NEXT_LOCALE')?.value ?? 'ar';
}

export const getTranslations = (locale: string) => {
  if (locale === 'ar') {
    return translations.ar;
  }
  return translations.en;
};
