Skip to content

Auto-redirect to localized version#2978

Open
OphirBleicher wants to merge 1 commit into
jdm-contrib:masterfrom
OphirBleicher:redirect-localized
Open

Auto-redirect to localized version#2978
OphirBleicher wants to merge 1 commit into
jdm-contrib:masterfrom
OphirBleicher:redirect-localized

Conversation

@OphirBleicher

Copy link
Copy Markdown
Contributor

Hi!
This PR fixes issue #496 to auto-redirect the users to localized (translated) versions of the site.
Here are the main things changed/updated/added:

Summary

  • The root page (/, /index or /index.html) redirects the users to localized versions. When users open the root page, they are automatically redirected using the new redirect.js to the localized versions (the language is read using navigator.language).
  • When there isn't a matching version for their language, the redirect.js file does nothing and the user is not redirected, so the root page serves the English version of the site (which is also good for SEO).
  • Added an English page (/en) to cleanly redirect instead of checking whether the language is English. The English page serves the exact same thing as the root page.
  • To support redirection for all new language, the contributors need also to add the language in header.html. Updated CONTRIBUTING.md to inform new contributors.
  • Updated the language switch dropdown to add a new "auto" option, which will transfer the users to the root page means they will be redirected.
  • It's important to say that if the users are not in the root page, they are not being redirected.

Testing

This was locally tested using Jekyll as described in README.md.

Thank you,
Ophir Bleicher.

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.

1 participant