Add plugin system and improve language handling

Add global and page-level plugin support Implement language-aware
content filtering Add month translations to language files Refactor date
formatting to use translations Move translation loading to plugin system
Improve content availability checks
This commit is contained in:
Ruben 2025-11-11 23:36:53 +01:00
parent 875408a27c
commit 24ee209e17
9 changed files with 196 additions and 30 deletions

View file

@ -155,13 +155,7 @@ function loadMetadata(string $dirPath, string $lang, string $defaultLang): ?arra
return $baseMetadata ?: null;
}
function loadTranslations(string $lang): array {
$translationFile = dirname(__DIR__) . "/custom/languages/$lang.ini";
if (file_exists($translationFile)) {
return parse_ini_file($translationFile) ?: [];
}
return [];
}
function buildNavigation(Context $ctx): array {
$navItems = [];
@ -177,13 +171,11 @@ function buildNavigation(Context $ctx): array {
}
// Check if content exists for current language
if ($ctx->currentLang !== $ctx->defaultLang) {
$contentFiles = findAllContentFiles($itemPath, $ctx->currentLang, $ctx->defaultLang, $ctx->availableLangs);
if ($ctx->currentLang !== $ctx->defaultLang && shouldHideUntranslated()) {
$hasLangContent = hasLanguageContent($itemPath, $ctx->currentLang, CONTENT_EXTENSIONS);
$hasLangMetadata = hasLanguageMetadata($itemPath, $ctx->currentLang);
// If no content files, check if metadata has title for this language
$hasContent = !empty($contentFiles) || ($metadata && isset($metadata['title']));
if (!$hasContent) continue;
if (!$hasLangContent && !$hasLangMetadata) continue;
}
// Extract title and build URL