Skip to content

Conversation

@bep
Copy link
Member

@bep bep commented Nov 28, 2025

Fixes #14204
Closes #14217

@gemini-code-assist
Copy link

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

@github-actions
Copy link

AI Detection Analysis 🔍

Confidence Score: 35%

Reasoning:
The pull request includes Go code changes along with well-formed test coverage. The described changes fix a specific issue, reference GitHub issue numbers, and follow a clear commit pattern that is typical of contributors familiar with structured collaborative development workflows. The writing is precise but not overly polished, and the test functions show nuanced understanding of language preferences in localization logic. While large language models can generate code and tests of this quality, nothing in the PR stands out as overly mechanical or generic, which would be more characteristic of AI-generated contributions.

Key Indicators:

  • Use of consistent Go idioms and realistic function naming (e.g., getTranslateFunc, Lookup)
  • Attention to edge cases and behavior under different capitalization formats in the tests, suggesting a human author with domain understanding
  • Code follows existing project conventions and provides relevant doc comments, indicating contextual awareness
  • The co-authored section is empty, suggesting a lone contributor, and there’s no explicit AI-assistance disclosure
  • The PR does not over-explain or contain excessive non-technical framing, which AI often introduces

Overall, this appears to be a thoughtful, human-written pull request, albeit one that could potentially be partially assisted by an AI in small ways (e.g., docstring phrasing or test scaffolding), but not generated outright.

✅ No strong indicators of AI generation detected

Fixes gohugoio#14204
Closes gohugoio#14217

Co-authored-by: Patrice Chalin <pchalin@gmail.com>
Copy link
Contributor

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 PR fixes issues #14204 and #14217 by changing the translation file selection logic to prefer the languageCode (e.g., "en-US") over the language key (e.g., "en") when both translation files are present. This allows for more specific translations to be used when a language has a specific regional variant configured.

Key Changes:

  • Introduced a new Lookup method in Translator to allow non-fallback lookups
  • Refactored translation function retrieval into a new getTranslateFunc method that tries languageCode first, then falls back to Lang
  • Added comprehensive integration tests for both scenarios

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
langs/i18n/translationProvider.go Refactored to use new getTranslateFunc method that implements the languageCode-first lookup logic
langs/i18n/i18n.go Added Lookup method for non-fallback translation function lookups
langs/i18n/i18n_integration_test.go Added integration tests covering languageCode preference and fallback scenarios with case-sensitivity variations

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

@bep
Copy link
Member Author

bep commented Nov 28, 2025

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the internationalization logic to prefer the languageCode when selecting a translation file, falling back to the language key. The changes are logical and are supported by new integration tests. I've made one suggestion in langs/i18n/translationProvider.go to improve the clarity and efficiency of the new translation function lookup logic. Otherwise, the changes look good.

Copy link
Contributor

@chalin chalin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @bep!

Matches the logic of the original PR #14205, but with cleaner code :)

Comment on lines +214 to +221
runTest := func(s string) {
b := hugolib.Test(t, s)
b.AssertFileContent("public/pt/index.html", `Greetings from pt!`)
}

runTest(filesTemplate)
runTest(strings.ReplaceAll(filesTemplate, "pt:", "PT:"))
runTest(strings.ReplaceAll(filesTemplate, "-- i18n/pt.yml --", "-- i18n/pT.yml --"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice approach to test variants.

@bep bep merged commit 6be463b into gohugoio:master Nov 28, 2025
12 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants