export const backendTranslations = {
  en: {
    'initializing': 'Initializing deployment',
    'creatingProject': 'Creating project',
    'gettingEnvironment': 'Getting environment ID',
    'environmentAvailable': 'Environment ID already available',
    'environmentRetrieved': 'Environment ID retrieved',
    'creatingApplication': 'Creating application',
    'configuringApplication': 'Configuring application',
    'creatingDomain': 'Creating domain',
    'deployingApplication': 'Deploying application',
    'waitingForSSL': 'Waiting for SSL certificate provisioning...',
    'waitingForStart': 'Waiting for application to start',
    'deploymentSuccess': 'Application deployed successfully',
    'verifyingHealth': 'Verifying application health',
  },
  nl: {
    'initializing': 'Implementatie initialiseren',
    'creatingProject': 'Project aanmaken',
    'gettingEnvironment': 'Omgeving ID ophalen',
    'environmentAvailable': 'Omgeving ID al beschikbaar',
    'environmentRetrieved': 'Omgeving ID opgehaald',
    'creatingApplication': 'Applicatie aanmaken',
    'configuringApplication': 'Applicatie configureren',
    'creatingDomain': 'Domein aanmaken',
    'deployingApplication': 'Applicatie implementeren',
    'waitingForSSL': 'Wachten op SSL-certificaat...',
    'waitingForStart': 'Wachten tot applicatie start',
    'deploymentSuccess': 'Applicatie succesvol geïmplementeerd',
    'verifyingHealth': 'Applicatie gezondheid verifiëren',
  },
  ar: {
    'initializing': 'جاري التهيئة',
    'creatingProject': 'إنشاء المشروع',
    'gettingEnvironment': 'الحصول على معرف البيئة',
    'environmentAvailable': 'معرف البيئة متاح بالفعل',
    'environmentRetrieved': 'تم استرداد معرف البيئة',
    'creatingApplication': 'إنشاء التطبيق',
    'configuringApplication': 'تكوين التطبيق',
    'creatingDomain': 'إنشاء النطاق',
    'deployingApplication': 'نشر التطبيق',
    'waitingForSSL': 'انتظار شهادة SSL...',
    'waitingForStart': 'انتظار بدء التطبيق',
    'deploymentSuccess': 'تم نشر التطبيق بنجاح',
    'verifyingHealth': 'التحقق من صحة التطبيق',
  },
} as const;

export type BackendLanguage = keyof typeof backendTranslations;
export type BackendTranslationKey = keyof typeof backendTranslations.en;

export function createTranslator(lang: BackendLanguage = 'en') {
  return (key: BackendTranslationKey, params?: Record<string, string | number>): string => {
    const translations = backendTranslations[lang] || backendTranslations.en;
    let text: string = translations[key];
    
    if (params) {
      Object.entries(params).forEach(([paramKey, value]) => {
        text = text.replace(`{${paramKey}}`, String(value));
      });
    }
    
    return text;
  };
}
