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

header and footer of 404 page are not localized #3056

Closed
4 tasks done
neicore opened this issue Oct 8, 2023 · 10 comments · Fixed by #3833 or #3858
Closed
4 tasks done

header and footer of 404 page are not localized #3056

neicore opened this issue Oct 8, 2023 · 10 comments · Fixed by #3833 or #3858
Labels
theme Related to the theme

Comments

@neicore
Copy link

neicore commented Oct 8, 2023

Describe the bug

I added a custom notFound and footer content in the themeConfig and it works as expected, but when I passed custom in themeConfig of a locale, the values didn't appear

Reproduction

In any vitepress project that has locale go to themeConfig of that locale and add custom notFound or footer values and they wont show up when you are in that locale

Expected behavior

When you add custom values of notFound or footer in themeConfig or a locale, they should show up if you are in that locale

System Info

System:
    OS: Linux 6.1 Manjaro Linux
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz
    Memory: 5.70 GB / 15.31 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 20.5.0 - ~/.nvm/versions/node/v20.5.0/bin/node
    Yarn: 1.22.19 - /usr/bin/yarn
    npm: 9.8.0 - ~/.nvm/versions/node/v20.5.0/bin/npm
  npmPackages:
    vitepress: ^1.0.0-rc.20 => 1.0.0-rc.20

Additional context

you can find my config here:
https://github.com/NuruProgramming/nyaraka/blob/main/docs/.vitepress/config.mts

currently it only has notFound property in locale

Validations

@neicore neicore added the bug: pending triage Maybe a bug, waiting for confirmation label Oct 8, 2023
@neicore neicore changed the title notFound & footer property values are not applied to respective locales notFound & footer property values are not applied to respective locale Oct 8, 2023
@narumi147
Copy link

same here, should be fixed before stable release!

@narumi147
Copy link

narumi147 commented Oct 25, 2023

Also there are several l18n related:

  • Also markdown.container.*Label can only be set in root, but cannot in locales

  • Tooltip for toggle dark mode is hardcoded.

    <VPSwitch
    title="toggle dark mode"
    class="VPSwitchAppearance"
    :aria-checked="isDark"
    @click="toggleAppearance"
    >

  • 404 page didn't respect locale: logo and navbar links

@dragomano
Copy link
Collaborator

Tooltip for the "Copy Code" button is hardcoded too.

@github-actions github-actions bot added the stale label Dec 26, 2023
@nozomuikuta
Copy link
Contributor

@brc-dd

I faced at this issue with the latest VitePress.

As far as I investigated, what's happening is like below:

  • notFoundPageData.relativePath is always an empty string regardless of actual page path the user is navigated to
  • Then, inside resolveSiteDataByRoute(), isActive() always returns false and localeIndex is fallen back to "root"
  • Then, siteData is made up by merging 2 root configs

Updating notFoundPageData.relativePath based on the current route would resolve this issue, but I'm not sure might be missing a reason why you set an empty string to it, and can't be so confident to submit a PR. 🙏

@brc-dd brc-dd added bug theme Related to the theme and removed bug: pending triage Maybe a bug, waiting for confirmation stale labels Apr 26, 2024
@brc-dd
Copy link
Member

brc-dd commented Apr 26, 2024

notFoundPageData.relativePath needs to be kept as empty because only one 404.html page is generated and I don't think any popular host supports localized error pages. We can however fix this problem similar to how we are determining the root link inside onMounted hook.

@nozomuikuta
Copy link
Contributor

@brc-dd

Thank you for the quick fix!
But, unfortunately #3833 resolved the issue only partially. 🙌

themeConfig for NotFound page is made up on mounted hook of NotFound.vue, which corresponds to main contents of the page. As a result, other components such as layout components (e.g VPFooter) is still not localized.

@brc-dd brc-dd reopened this Apr 28, 2024
@brc-dd brc-dd changed the title notFound & footer property values are not applied to respective locale header and footer of 404 are not localized Apr 28, 2024
@brc-dd brc-dd changed the title header and footer of 404 are not localized header and footer of 404 page are not localized Apr 28, 2024
@brc-dd
Copy link
Member

brc-dd commented Apr 28, 2024

I don't think there is any way to fix that except to render 404 completely on client 👀

@narumi147
Copy link

@brc-dd will above mentioned container labels support locales? it seems still not fixed yet

@brc-dd
Copy link
Member

brc-dd commented May 2, 2024

You can customize those but cannot override based on locale. Track #3141 (comment) for that. The current workaround is to always specify titles on blocks.

@narumi147
Copy link

Yeah, customizable but not localized, I will track that issue, thanks. though it is inactive for half a year already

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
theme Related to the theme
Projects
None yet
5 participants