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:
parent
875408a27c
commit
24ee209e17
9 changed files with 196 additions and 30 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue