getPlatformName(); } catch (\Exception $e) { $params['platformName'] = 'SysCMS'; } } if (!empty($params)) { foreach ($params as $param => $value) { if ($value !== null) { $translation = str_replace(":{$param}", (string)$value, $translation); } } } return $translation; } /** * Load translations from files */ protected static function loadTranslations(): void { self::$translations = []; // Load standard paths foreach (self::$paths as $namespace => $path) { self::loadFromPath($path); } // Load theme overrides (highest priority) foreach (self::$themePaths as $path) { self::loadFromPath($path); } } /** * Load translations from a specific path */ protected static function loadFromPath(string $path): void { $localePath = $path . '/' . self::$locale; if (is_dir($localePath)) { $files = glob($localePath . '/*.json'); foreach ($files as $file) { $filename = basename($file, '.json'); $content = file_get_contents($file); if ($content === false) { continue; } $translations = json_decode($content, true); if (is_array($translations)) { // Flatten the translations to support dot notation $flatTranslations = self::flatten($translations); foreach ($flatTranslations as $key => $value) { self::$translations[$filename . '.' . $key] = $value; } } } } } /** * Flatten a multi-dimensional associative array with dot notation. * * @param array $array * @param string $prepend * @return array */ protected static function flatten(array $array, string $prepend = ''): array { $results = []; foreach ($array as $key => $value) { if (is_array($value) && !empty($value)) { $results = array_merge($results, self::flatten($value, $prepend . $key . '.')); } else { $results[$prepend . $key] = $value; } } return $results; } }