Skip to content

Change navbar-lang-selector behavior#53804

Merged
k8s-ci-robot merged 1 commit intokubernetes:mainfrom
paulofponciano:issue-53803
Mar 28, 2026
Merged

Change navbar-lang-selector behavior#53804
k8s-ci-robot merged 1 commit intokubernetes:mainfrom
paulofponciano:issue-53803

Conversation

@paulofponciano
Copy link
Copy Markdown
Contributor

@paulofponciano paulofponciano commented Dec 25, 2025

Description

The current navbar-lang-selector behavior lists all languages in the dropdown even when no translations are available for the current page. When a user selects a language, they are redirected to that language's home page instead of a translated version of the current page.
This misleads users into thinking translations exist for the page, and they only discover it's a fallback behavior after being redirected to the home page.

Proposed changes in this PR:

  • Available languages (with translations for the current page) are listed first with default formatting
  • Remaining languages (available on other pages but not the current one) are listed afterward, greyed out, with a home icon that links to the site's landing page in the corresponding language

Repo files:

  • /layouts/partials/navbar-lang-selector.html
  • /assets/scss/_k8s_sidebar-tree.scss
  • /i18n/en/en.toml

Example pages with current behavior:

Issue

Closes: #53803

@k8s-ci-robot k8s-ci-robot added sig/docs Categorizes an issue or PR as relevant to SIG Docs. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Dec 25, 2025
@netlify
Copy link
Copy Markdown

netlify bot commented Dec 25, 2025

Pull request preview available for checking

Built without sensitive environment variables

Name Link
🔨 Latest commit 1ee4c00
🔍 Latest deploy log https://app.netlify.com/projects/kubernetes-io-main-staging/deploys/69c04117c9ed25000821f4c8
😎 Deploy Preview https://deploy-preview-53804--kubernetes-io-main-staging.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@lmktfy
Copy link
Copy Markdown
Member

lmktfy commented Jan 1, 2026

/area web-development
/retitle Change navbar-lang-selector behavior

@k8s-ci-robot k8s-ci-robot changed the title Proposed change to navbar-lang-selector behavior Change navbar-lang-selector behavior Jan 1, 2026
@k8s-ci-robot k8s-ci-robot added the area/web-development Issues or PRs related to the kubernetes.io's infrastructure, design, or build processes label Jan 1, 2026
Copy link
Copy Markdown
Member

@lmktfy lmktfy left a comment

Choose a reason for hiding this comment

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

Here's a challenge: how do we let people know that the other localization is available, albeit not for the page they have open?


Maybe we show some of the localizations in gray text, as a way to indicate that the specific page isn't localized, but with a hint that another page might be.

@paulofponciano
Copy link
Copy Markdown
Contributor Author

Here's a challenge: how do we let people know that the other localization is available, albeit not for the page they have open?

Maybe we show some of the localizations in gray text, as a way to indicate that the specific page isn't localized, but with a hint that another page might be.

Thanks for bringing up this perspective.

I've pushed a proposal to staging addressing these points, where we now use class="dropdown-item-text text-muted" listing all the languages identified on the Home page.

Screenshot 2026-01-03 at 10 44 31 AM (3)

Also, as another option: just show a message (This page is only available in {{ $.Language.LanguageName }}) indicating the page is only available in that language — implying the limitation is specific to that page.

Screenshot 2026-01-03 at 9 48 27 AM

Once there's at least one other language, it follows the default behavior.

Screenshot 2026-01-03 at 9 51 03 AM

@paulofponciano paulofponciano requested a review from lmktfy January 17, 2026 20:46
{{ if $hasTranslations }}
<a class="dropdown-item" href="{{ .RelPermalink }}">{{ .Language.LanguageName }}</a>
{{ else }}
<span class="dropdown-item-text text-muted" title="This page is not available in {{ .Language.LanguageName }}">
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Our site is, as you know, localized. This needs to use Hugo i18n; see other partials and also https://github.com/kubernetes/website/tree/main/i18n

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thank you @lmktfy for bringing up this concern.
To address this, I've initially added the keys to en.toml and pt-br.toml like this:

[page_not_available_in_language]
other = "This page is not available in {{ .Language }}"

In /layouts/partials/navbar-lang-selector.html we use the i18n key / translation identifier page_not_available_in_language.
The fallback for this case (when the key doesn't exist in somelanguage.toml) is to use language_alternatives = ["en"] for each language (from hugo.toml).

@lmktfy
Copy link
Copy Markdown
Member

lmktfy commented Jan 17, 2026

Apart from a (big) localization concern, I like both the ambition and the approach.

@k8s-ci-robot k8s-ci-robot added area/localization General issues or PRs related to localization language/en Issues or PRs related to English language language/pt Issues or PRs related to Portuguese language labels Jan 18, 2026
@paulofponciano paulofponciano requested a review from lmktfy January 30, 2026 10:58
Comment thread i18n/pt-br/pt-br.toml
@lmktfy
Copy link
Copy Markdown
Member

lmktfy commented Feb 15, 2026

Thanks for the work so far on this. We haven't many people willing to review pull requests. You can help - that might not be obvious, but you can, GitHub just allows you to write feedback on pull requests.

One thing I'd like you to do: squash the commits down on this PR.

Do that, and drop the Portuguese strings, and it could well be good to merge.

@paulofponciano
Copy link
Copy Markdown
Contributor Author

/remove-language pt

@k8s-ci-robot k8s-ci-robot removed the language/pt Issues or PRs related to Portuguese language label Feb 15, 2026
@paulofponciano
Copy link
Copy Markdown
Contributor Author

Thanks for the work so far on this. We haven't many people willing to review pull requests. You can help - that might not be obvious, but you can, GitHub just allows you to write feedback on pull requests.

One thing I'd like you to do: squash the commits down on this PR.

Do that, and drop the Portuguese strings, and it could well be good to merge.

Thanks @lmktfy.
I've dropped the pt-br changes and squashed the commits. Here's a netlify to validate the behavior.

@lmktfy
Copy link
Copy Markdown
Member

lmktfy commented Feb 15, 2026

The current navbar-lang-selector behavior lists all languages in the dropdown even when no translations are available for the current page.

I don't think it does. For example, go to https://kubernetes.io/docs/reference/kubectl/ ns look at which languages you can choose.


We could improve it further, which is what I thought this PR might do.

Looking at https://deploy-preview-53804--kubernetes-io-main-staging.netlify.app/docs/reference/kubectl/ I think what we should show in the nav bar is:

and then after those languages, list the remaining languages: remaining in that some other page on the site supports them, but not this page. The remaining languages should be greyed out or otherwise marked unavailable. I might show an icon after each "remaining" language that is not greyed out, and if you click it you go to the landing page for the site in that language.

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Feb 16, 2026
@paulofponciano paulofponciano force-pushed the issue-53803 branch 2 times, most recently from aee97b0 to c81d3cc Compare February 16, 2026 21:12
@paulofponciano
Copy link
Copy Markdown
Contributor Author

paulofponciano commented Feb 16, 2026

The current navbar-lang-selector behavior lists all languages in the dropdown even when no translations are available for the current page.

I don't think it does. For example, go to https://kubernetes.io/docs/reference/kubectl/ and look at which languages you can choose.

We could improve it further, which is what I thought this PR might do.

Looking at https://deploy-preview-53804--kubernetes-io-main-staging.netlify.app/docs/reference/kubectl/ I think what we should show in the nav bar is:

and then after those languages, list the remaining languages: remaining in that some other page on the site supports them, but not this page. The remaining languages should be greyed out or otherwise marked unavailable. I might show an icon after each "remaining" language that is not greyed out, and if you click it you go to the landing page for the site in that language.

I believe it's now closer to meeting the suggestions made in this same PR.
The navigation bar now lists the available languages first with the default formatting, while the remaining languages (unavailable for the current page but available on other pages) are listed afterward, greyed out, with a home icon that links to the site's landing page in the corresponding language. Could you please take a look, @lmktfy?

https://deploy-preview-53804--kubernetes-io-main-staging.netlify.app/docs/reference/kubectl/

@lmktfy
Copy link
Copy Markdown
Member

lmktfy commented Mar 15, 2026

Well, personally, I think this is a nice improvement.
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 15, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

LGTM label has been added.

DetailsGit tree hash: 129993555387a956cdf94e201e2f0b866082be15

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 15, 2026
@Caesarsage
Copy link
Copy Markdown
Contributor

Thanks for this improvement.

But the mobile view is still broken, the text are not showing

image

@paulofponciano
Copy link
Copy Markdown
Contributor Author

paulofponciano commented Mar 15, 2026

/hold
until fix the behavior when accessed via mobile browser

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 15, 2026
@paulofponciano
Copy link
Copy Markdown
Contributor Author

/unhold

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 17, 2026
@SayakMukhopadhyay
Copy link
Copy Markdown
Member

This PR is pertinent google/docsy#2303

This issue gets fixed upstream in 0.13.0 wherein untranslated locales are disabled. @paulofponciano as a request, can you please add a TODO at the top of navbar-lang-selector.html that notes that this issue gets fixed in 0.13.0. It will help me in figuring out what to keep and discard during that upgrade.

@paulofponciano
Copy link
Copy Markdown
Contributor Author

This PR is pertinent google/docsy#2303

This issue gets fixed upstream in 0.13.0 wherein untranslated locales are disabled. @paulofponciano as a request, can you please add a TODO at the top of navbar-lang-selector.html that notes that this issue gets fixed in 0.13.0. It will help me in figuring out what to keep and discard during that upgrade.

Thanks for connecting the dots @SayakMukhopadhyay. Added the TODO for tracking.
Let me know if there's anything else I can help with.

@SayakMukhopadhyay
Copy link
Copy Markdown
Member

Thanks for addressing the reviews

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 23, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

LGTM label has been added.

DetailsGit tree hash: 20b15af3c398894d3b5a7c5a974f5c948508df1e

@lmktfy
Copy link
Copy Markdown
Member

lmktfy commented Mar 28, 2026

/approve

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lmktfy

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 28, 2026
@k8s-ci-robot k8s-ci-robot merged commit 801a9a1 into kubernetes:main Mar 28, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area/localization General issues or PRs related to localization area/web-development Issues or PRs related to the kubernetes.io's infrastructure, design, or build processes cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. language/en Issues or PRs related to English language lgtm "Looks good to me", indicates that a PR is ready to be merged. sig/docs Categorizes an issue or PR as relevant to SIG Docs. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Proposed change to navbar-lang-selector behavior

5 participants