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

Language switch to currently opened page #349

Open
gospodima opened this issue May 3, 2024 · 5 comments · May be fixed by #338
Open

Language switch to currently opened page #349

gospodima opened this issue May 3, 2024 · 5 comments · May be fixed by #338

Comments

@gospodima
Copy link

Hello,

Thank you for maintaing this repo

I would like to make an adjustment to the language switch functionality so that it redirects to the currently opened page instead of some default page.

From what I can see, the only option currently available to implement this is by adding href="{{ pathto(alt.link + pagename) }}" to header.html. And this is only possible by copying and overwriting header.html template.

Is there a solution that doesn't require overwriting the entire header template?

@2bndy5
Copy link
Collaborator

2bndy5 commented May 3, 2024

I guess we can apply that patch, but what happens if a version of the site does not have the page that pagename points to? I think this is why it is currently the way it is.

@gospodima
Copy link
Author

gospodima commented May 3, 2024

As far as I understand, Sphinx uses gettext with .po files for localization. I.e. the page structure should be the same and in case there is no translation - default language will be shown.

Or do you mean there could be an issue with some other localization approaches?

@2bndy5
Copy link
Collaborator

2bndy5 commented May 3, 2024

the page structure should be the same

How accurate is this assumption? You could actually do some clever stuff with toctree directives, so that some languages have special pages or simply elide a page for a language (usually for legal reasons).

@2bndy5
Copy link
Collaborator

2bndy5 commented May 3, 2024

Also, FYI, we have contribution guidelines about unwanted changes. Notice the part about the src directory (the HTML templates included).

In upstream mkdocs-material, they too don't add to the base URL either.

Fortunately, as for overriding the template, this will become much easier when we merge in the updates from upstream (#338). The file to override would be partials/alternate.html (no longer the entire partials/header.html).

@gospodima
Copy link
Author

The file to override would be partials/alternate.html

This looks like a good option. Thank you!

@2bndy5 2bndy5 linked a pull request Jul 5, 2024 that will close this issue
4 tasks
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 a pull request may close this issue.

2 participants