import {getRequestConfig} from 'next-intl/server';
import ro from './messages/ro.json';
import en from './messages/en.json';

// Can be imported from a shared config
export const locales = ['ro', 'en'] as const;

const messages = {
  ro,
  en
} as const;

export default getRequestConfig(async ({locale}) => {
  // Ensure locale has a value, default to 'ro' if undefined
  const validLocale = (locale || 'ro') as keyof typeof messages;

  return {
    locale: validLocale,
    messages: messages[validLocale]
  };
});