Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: new language switch behaviour #1159

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

HarisDotParis
Copy link

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.
  • I have enabled maintainer edits for this PR.
  • 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.
  • This change does not include any CDN resources/links.
  • 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.

…weight but linking to translations if available

feat: if language switch shows language codes (instead of full language name), those codes are now uppercase
feat: translation list in post headers are replaced by links to translations in page headers - the old translation list in the post header can still be enabled using the boolean parameter "showTranslationListInPosts" (i.e. to turn it back on, add the parameter to your hugo.toml and set it to true)
@sonarcloud
Copy link

sonarcloud bot commented Feb 13, 2023

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

@adityatelange
Copy link
Owner

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.

@HarisDotParis
Copy link
Author

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.

@algo-se
Copy link

algo-se commented Feb 26, 2023

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! 😄

@sonarcloud
Copy link

sonarcloud bot commented Oct 12, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Language selector to forward to translated page
4 participants