-
Notifications
You must be signed in to change notification settings - Fork 0
Fix for PDF logic on translations page #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…orts in configuration
…nd improve PDF download logic
…ndling in guide translations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request refactors and improves the handling of official and community translation components, PDF resource matching, and output formats for guide translations. The changes enhance maintainability, ensure consistent language handling, and improve PDF download logic and output format configuration.
- Refactored official version component to always use the default site language and dynamically match PDF variants
- Improved PDF resource lookup logic with better language code normalization and fallback mechanisms
- Added new output formats for more granular JSON exports and updated Hugo configuration
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| site/hugo.yaml | Added new output formats and updated module configuration for i18n support |
| module/layouts/_partials/functions/get-guide-translations-for-version.html | Improved PDF resource matching with language normalization and fallback logic |
| module/layouts/_partials/components/translations/official-version.html | Complete refactor to use default site language and dynamic PDF matching |
| module/layouts/_partials/components/translations/community-translations2.html | Added development tooltip for debugging resource lookup |
| module/layouts/_partials/components/translations/community-translations.html | Removed entire legacy component file |
Comments suppressed due to low confidence (1)
module/layouts/_partials/functions/get-guide-translations-for-version.html:78
- This is using JavaScript-style comments (//) in Hugo template code. Hugo templates use {{/* /}} for comments. This should be changed to {{/ Fallback: check the translation page's own resources */}}.
// Fallback: check the translation page’s own resources
| {{ $langKey := lower $lang }} | ||
| {{ $pdfResource := index $pdfsByLang $langKey }} | ||
|
|
||
| // Fallback: check the translation page’s own resources |
Copilot
AI
Aug 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is using JavaScript-style comments (//) in Hugo template code. Hugo templates use {{/* /}} for comments. This should be changed to {{/ Look up PDF by normalized lang */}}.
| // Fallback: check the translation page’s own resources | |
| {{/* Look up PDF by normalized lang */}} | |
| {{ $langKey := lower $lang }} | |
| {{ $pdfResource := index $pdfsByLang $langKey }} | |
| {{/* Fallback: check the translation page’s own resources */}} |
| <a href="#" class="btn btn-primary btn-sm disabled" title="PDF not available at {{ $pdfPattern }}"> <i class="fa-solid fa-ban me-1"></i>EN (US) </a> | ||
| {{- end }} | ||
| {{ else }} | ||
| <a href="#" class="btn btn-primary btn-sm disabled" title="PDF not available at {{ $pdfPattern }}"> <i class="fa-solid fa-ban me-1"></i>{{ $defaultSite.Language | upper }}</a> |
Copilot
AI
Aug 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable $defaultSite.Language | upper will not produce the expected language code. $defaultSite.Language is a Language object, not a string. It should be $defaultSite.Language.Lang | upper to get the language code.
| <a href="#" class="btn btn-primary btn-sm disabled" title="PDF not available at {{ $pdfPattern }}"> <i class="fa-solid fa-ban me-1"></i>{{ $defaultSite.Language | upper }}</a> | |
| <a href="#" class="btn btn-primary btn-sm disabled" title="PDF not available at {{ $pdfPattern }}"> <i class="fa-solid fa-ban me-1"></i>{{ $defaultSite.Language.Lang | upper }}</a> |
| <a href="#" class="btn btn-primary btn-sm disabled" title="PDF not available at {{ $pdfPattern }}"> <i class="fa-solid fa-ban me-1"></i>EN-US</a> | ||
| {{- end }} | ||
| {{ else }} | ||
| <a href="#" class="btn btn-primary btn-sm disabled" title="PDF not available at {{ $pdfPattern }}"> <i class="fa-solid fa-ban me-1"></i>{{ $defaultSite.Language | upper }}</a> |
Copilot
AI
Aug 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable $defaultSite.Language | upper will not produce the expected language code. $defaultSite.Language is a Language object, not a string. It should be $defaultSite.Language.Lang | upper to get the language code.
| <a href="#" class="btn btn-primary btn-sm disabled" title="PDF not available at {{ $pdfPattern }}"> <i class="fa-solid fa-ban me-1"></i>{{ $defaultSite.Language | upper }}</a> | |
| <a href="#" class="btn btn-primary btn-sm disabled" title="PDF not available at {{ $pdfPattern }}"> <i class="fa-solid fa-ban me-1"></i>{{ $defaultSite.Language.Lang | upper }}</a> |
This pull request refactors and improves the handling of official and community translation components, PDF resource matching, and output formats for guide translations. The changes enhance maintainability, ensure consistent language handling, and improve PDF download logic and output format configuration.
Official and Community Translation Components
official-version.htmlto always use the default site language for displaying the official guide version, regardless of the current page's language context. This includes improved logic for selecting the latest guide page and contributors, and now dynamically matches all available PDF variants for the official version. [1] [2]official-version.htmlto loop over all matched PDF resources for the default language, showing a button for each available language variant and a disabled button if none are found. [1] [2]community-translations.htmlpartial, likely in favor of a refactored or replacement component.PDF Resource Matching Logic
get-guide-translations-for-version.htmlby normalizing language codes to lowercase and providing a fallback to check the translation page's own resources if a PDF is not found in the main mapping. [1] [2]Output Formats and Module Configuration
languages,translations,guide-translations) insite/hugo.yamlfor more granular JSON and plain text outputs, and updated module imports and mounts for i18n support.Miscellaneous
community-translations2.htmlto display resource lookup debug info.