hugo-PaperMod
hugo-PaperMod copied to clipboard
feat: new language switch behaviour
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.
Kudos, SonarCloud Quality Gate passed!
0 Bugs
0 Vulnerabilities
0 Security Hotspots
0 Code Smells
No Coverage information
0.0% Duplication
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
So that if the user wants to switch to their preferred language version,they can happily move there.
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.
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! 😄
Kudos, SonarCloud Quality Gate passed!
0 Bugs
0 Vulnerabilities
0 Security Hotspots
0 Code Smells
No Coverage information
0.0% Duplication
Any updates on this? Would love this feature. Having two translation buttons is very confusing.