From 79eb010fa5f6a1ca84260dbea8fce6325ba680fc Mon Sep 17 00:00:00 2001 From: Edwin Noorlander Date: Sat, 22 Nov 2025 16:14:59 +0100 Subject: [PATCH] Implement language-specific content system MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Rename guide files: nl.md → nl.codepress.md, en.md → uk.codepress.md - Add language filtering in scanDirectory() for nl.* and uk.* files/folders - Update formatDisplayName() to remove language prefixes from display names - Update getGuidePage() to use new naming convention (en → uk mapping) - Content with nl. prefix only shows when Dutch language is selected - Content with uk. prefix only shows when English language is selected --- engine/core/class/CodePressCMS.php | 19 +++++++++++++++++-- guide/{nl.md => nl.codepress.md} | 0 guide/{en.md => uk.codepress.md} | 0 3 files changed, 17 insertions(+), 2 deletions(-) rename guide/{nl.md => nl.codepress.md} (100%) rename guide/{en.md => uk.codepress.md} (100%) diff --git a/engine/core/class/CodePressCMS.php b/engine/core/class/CodePressCMS.php index 4d0167e..ac3630a 100644 --- a/engine/core/class/CodePressCMS.php +++ b/engine/core/class/CodePressCMS.php @@ -109,6 +109,15 @@ class CodePressCMS { foreach ($items as $item) { if ($item[0] === '.') continue; + // Skip language-specific content that doesn't match current language + if (preg_match('/^(nl|uk)\./', $item)) { + $langPrefix = substr($item, 0, 2); + if (($langPrefix === 'nl' && $this->currentLanguage !== 'nl') || + ($langPrefix === 'uk' && $this->currentLanguage !== 'en')) { + continue; + } + } + $path = $dir . '/' . $item; $relativePath = $prefix ? $prefix . '/' . $item : $item; @@ -510,6 +519,11 @@ class CodePressCMS { * @return string Formatted display name */ private function formatDisplayName($filename) { + // Remove language prefixes (nl. or uk.) from display names + if (preg_match('/^(nl|uk)\.(.+)$/', $filename, $matches)) { + $filename = $matches[2]; + } + // Handle special cases first if (strtolower($filename) === 'phpinfo') { return 'phpinfo'; @@ -627,10 +641,11 @@ class CodePressCMS { */ private function getGuidePage() { $lang = $this->currentLanguage; - $guideFile = __DIR__ . '/../../../guide/' . $lang . '.md'; + $langCode = ($lang === 'en') ? 'uk' : $lang; // Map 'en' to 'uk' for file naming + $guideFile = __DIR__ . '/../../../guide/' . $langCode . '.codepress.md'; if (!file_exists($guideFile)) { - $guideFile = __DIR__ . '/../../../guide/en.md'; // Fallback to English + $guideFile = __DIR__ . '/../../../guide/uk.codepress.md'; // Fallback to English (UK) } $content = file_get_contents($guideFile); diff --git a/guide/nl.md b/guide/nl.codepress.md similarity index 100% rename from guide/nl.md rename to guide/nl.codepress.md diff --git a/guide/en.md b/guide/uk.codepress.md similarity index 100% rename from guide/en.md rename to guide/uk.codepress.md