$value) { $translation = str_replace(':' . $param, $value, $translation); } } return $translation; } private static function loadTranslations() { // Load current locale $localePath = __DIR__ . '/../lang/' . self::$currentLocale . '.php'; if (file_exists($localePath)) { self::$translations[self::$currentLocale] = require $localePath; } // Load fallback locale if different if (self::$currentLocale !== self::$fallbackLocale) { $fallbackPath = __DIR__ . '/../lang/' . self::$fallbackLocale . '.php'; if (file_exists($fallbackPath)) { self::$translations[self::$fallbackLocale] = require $fallbackPath; } } } public static function getAllTranslations() { return self::$translations; } public static function getSupportedLocales() { return self::$supportedLocales; } // Helper function for date formatting public static function formatDate($timestamp, $format = 'full') { $locale = self::$currentLocale . '_' . strtoupper(self::$currentLocale); setlocale(LC_TIME, $locale . '.UTF-8'); $formats = [ 'full' => '%A %d %B %Y', 'long' => '%d %B %Y', 'medium' => '%d %b %Y', 'short' => '%d/%m/%Y' ]; return strftime($formats[$format] ?? $formats['full'], $timestamp); } // Helper function for number formatting public static function formatNumber($number, $decimals = 0) { $locale = self::$currentLocale . '_' . strtoupper(self::$currentLocale); $formatter = new NumberFormatter($locale, NumberFormatter::DECIMAL); $formatter->setAttribute(NumberFormatter::FRACTION_DIGITS, $decimals); return $formatter->format($number); } // Helper function for currency formatting public static function formatCurrency($amount, $currency = 'EGP') { $locale = self::$currentLocale . '_' . strtoupper(self::$currentLocale); $formatter = new NumberFormatter($locale, NumberFormatter::CURRENCY); return $formatter->formatCurrency($amount, $currency); } }