Change navbar-lang-selector behavior#53804
Conversation
✅ Pull request preview available for checkingBuilt without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
/area web-development |
lmktfy
left a comment
There was a problem hiding this comment.
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.
| {{ 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 }}"> |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
There was a problem hiding this comment.
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).
|
Apart from a (big) localization concern, I like both the ambition and the approach. |
|
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. |
5264634 to
cedc30b
Compare
|
/remove-language pt |
Thanks @lmktfy. |
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. |
aee97b0 to
c81d3cc
Compare
I believe it's now closer to meeting the suggestions made in this same PR. https://deploy-preview-53804--kubernetes-io-main-staging.netlify.app/docs/reference/kubectl/ |
956e3f8 to
2f75ecf
Compare
|
Well, personally, I think this is a nice improvement. |
|
LGTM label has been added. DetailsGit tree hash: 129993555387a956cdf94e201e2f0b866082be15 |
|
/hold |
7b5d594 to
7d9cdec
Compare
|
/unhold |
|
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 |
9208af2 to
ee35507
Compare
ee35507 to
1ee4c00
Compare
Thanks for connecting the dots @SayakMukhopadhyay. Added the TODO for tracking. |
|
Thanks for addressing the reviews /lgtm |
|
LGTM label has been added. DetailsGit tree hash: 20b15af3c398894d3b5a7c5a974f5c948508df1e |
|
/approve |
|
[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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |




Description
The current
navbar-lang-selectorbehavior 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:
Repo files:
/layouts/partials/navbar-lang-selector.html/assets/scss/_k8s_sidebar-tree.scss/i18n/en/en.tomlExample pages with current behavior:
Issue
Closes: #53803