/**
 * Internationalization (i18n) System
 *
 * Unterstuetzt dieselben 7 Sprachen wie das Studio Frontend:
 * de, en, tr, ar, ru, uk, pl
 *
 * Translations are split per language into separate files:
 * i18n-de.ts, i18n-en.ts, i18n-tr.ts, i18n-ar.ts, i18n-ru.ts, i18n-uk.ts, i18n-pl.ts
 */

import { de } from './i18n-de'
import { en } from './i18n-en'
import { tr } from './i18n-tr'
import { ar } from './i18n-ar'
import { ru } from './i18n-ru'
import { uk } from './i18n-uk'
import { pl } from './i18n-pl'

export type Language = 'de' | 'en' | 'tr' | 'ar' | 'ru' | 'uk' | 'pl'

export const LANGUAGES: { code: Language; name: string; flag: string }[] = [
  { code: 'de', name: 'Deutsch', flag: '🇩🇪' },
  { code: 'en', name: 'English', flag: '🇬🇧' },
  { code: 'tr', name: 'Türkçe', flag: '🇹🇷' },
  { code: 'ar', name: 'العربية', flag: '🇸🇦' },
  { code: 'ru', name: 'Русский', flag: '🇷🇺' },
  { code: 'uk', name: 'Українська', flag: '🇺🇦' },
  { code: 'pl', name: 'Polski', flag: '🇵🇱' },
]

export const DEFAULT_LANGUAGE: Language = 'de'

// RTL Languages
export const RTL_LANGUAGES: Language[] = ['ar']

export function isRTL(lang: Language): boolean {
  return RTL_LANGUAGES.includes(lang)
}

// Translations assembled from per-language modules
export const translations: Record<Language, Record<string, string>> = {
  de,
  en,
  tr,
  ar,
  ru,
  uk,
  pl,
}

/**
 * Get translation for key
 */
export function t(key: string, lang: Language = DEFAULT_LANGUAGE): string {
  return translations[lang]?.[key] || translations[DEFAULT_LANGUAGE]?.[key] || key
}

/**
 * Get all translations for a language
 */
export function getTranslations(lang: Language): Record<string, string> {
  return translations[lang] || translations[DEFAULT_LANGUAGE]
}
