Implement language-specific content system
- 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
This commit is contained in:
parent
9bb21579f7
commit
79eb010fa5
@ -109,6 +109,15 @@ class CodePressCMS {
|
|||||||
foreach ($items as $item) {
|
foreach ($items as $item) {
|
||||||
if ($item[0] === '.') continue;
|
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;
|
$path = $dir . '/' . $item;
|
||||||
$relativePath = $prefix ? $prefix . '/' . $item : $item;
|
$relativePath = $prefix ? $prefix . '/' . $item : $item;
|
||||||
|
|
||||||
@ -510,6 +519,11 @@ class CodePressCMS {
|
|||||||
* @return string Formatted display name
|
* @return string Formatted display name
|
||||||
*/
|
*/
|
||||||
private function formatDisplayName($filename) {
|
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
|
// Handle special cases first
|
||||||
if (strtolower($filename) === 'phpinfo') {
|
if (strtolower($filename) === 'phpinfo') {
|
||||||
return 'phpinfo';
|
return 'phpinfo';
|
||||||
@ -627,10 +641,11 @@ class CodePressCMS {
|
|||||||
*/
|
*/
|
||||||
private function getGuidePage() {
|
private function getGuidePage() {
|
||||||
$lang = $this->currentLanguage;
|
$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)) {
|
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);
|
$content = file_get_contents($guideFile);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user