Skip to content

Conversation

@MrHinsh
Copy link
Member

@MrHinsh MrHinsh commented Aug 11, 2025

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

  • Refactored official-version.html to 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]
  • Updated PDF download buttons in official-version.html to 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]
  • Removed the entire legacy community-translations.html partial, likely in favor of a refactored or replacement component.

PDF Resource Matching Logic

  • Improved PDF resource lookup in get-guide-translations-for-version.html by 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

  • Added new output formats (languages, translations, guide-translations) in site/hugo.yaml for more granular JSON and plain text outputs, and updated module imports and mounts for i18n support.

Miscellaneous

  • Added a development-only tooltip to desktop translation rows in community-translations2.html to display resource lookup debug info.

@MrHinsh MrHinsh self-assigned this Aug 11, 2025
Copilot AI review requested due to automatic review settings August 11, 2025 08:49
@MrHinsh MrHinsh changed the title Fix for pd fs Fix for PDF logic on translations page Aug 11, 2025
@MrHinsh MrHinsh added this pull request to the merge queue Aug 11, 2025
Copy link

Copilot AI left a 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
Copy link

Copilot AI Aug 11, 2025

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 */}}.

Suggested change
// 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 */}}

Copilot uses AI. Check for mistakes.
<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>
Copy link

Copilot AI Aug 11, 2025

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.

Suggested change
<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>

Copilot uses AI. Check for mistakes.
<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>
Copy link

Copilot AI Aug 11, 2025

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.

Suggested change
<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>

Copilot uses AI. Check for mistakes.
Merged via the queue into main with commit 7d5197f Aug 11, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants