hugo-PaperMod icon indicating copy to clipboard operation
hugo-PaperMod copied to clipboard

feat: new language switch behaviour

Open HarisDotParis opened this issue 2 years ago • 6 comments

What does this PR change? What problem does it solve?

Currently, the language switch always links to each language's main page and not any possible translation of the page. This PR changes the way the language switch works significantly. The language switch still lists all languages available according to their "weight", but if there is a translation, then that translation will be linked, otherwise that language's main page as before. As this replaces the need for the translation list in posts, translation lists in posts have been made optional with a new boolean parameter "showTranslationListInPosts". I have tested the changes extensively and with different parameters and language settings.

Was the change discussed in an issue or in the Discussions before?

Closes #1065

PR Checklist

  • [ ] This change adds/updates translations and I have used the template present here.
  • [x] I have enabled maintainer edits for this PR.
  • [x] I have verified that the code works as described/as intended.
  • [ ] This change adds a Social Icon which has a permissive license to use it.
  • [x] This change does not include any CDN resources/links.
  • [x] This change does not include any unrelated scripts such as bash and python scripts.
  • [ ] This change updates the overridden internal templates from HUGO's repository.

HarisDotParis avatar Feb 13 '23 21:02 HarisDotParis

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

sonarqubecloud[bot] avatar Feb 13 '23 21:02 sonarqubecloud[bot]

Hi @HarisDotParis there is a reason that the language switch always links to each language's main page and not any possible translation of the page. And it is: regularity. The website should have regularity in the way it behaves upon a certain action.

For the case where the particular page has a translated page listed, we have the translations, mentioned right under the title of the page image So that if the user wants to switch to their preferred language version,they can happily move there.

adityatelange avatar Feb 17 '23 18:02 adityatelange

I am sorry, but I consider this deviating from the regular behaviour of language switches. Most multilingual websites forward to the translation if possible, and only to the main page if no translation is available. This also makes sense, because most users switching languages want to read the same content in either their own or the original language.

Regularity only for the sake of it doesn't make sense. Always forwarding to the main page may create regularity, but it makes a simple feature more complex, and this makes the UX worse.

HarisDotParis avatar Feb 17 '23 19:02 HarisDotParis

I think the site would have greater regularity if there was only one switch (in the nav bar) and not two (nav bar + posts meta), but then the switch in nav bar should translate the page and not go to home. That said, it's not a big deal, just my 2 cents.

Awesome theme btw! 😄

algo-se avatar Feb 26 '23 00:02 algo-se

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

sonarqubecloud[bot] avatar Oct 12 '23 14:10 sonarqubecloud[bot]

Any updates on this? Would love this feature. Having two translation buttons is very confusing.

jakoblover avatar Jun 18 '24 13:06 jakoblover