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

Hugo doesn't properly use localisation keys #49649

Open
SayakMukhopadhyay opened this issue Feb 5, 2025 · 5 comments · May be fixed by #49643
Open

Hugo doesn't properly use localisation keys #49649

SayakMukhopadhyay opened this issue Feb 5, 2025 · 5 comments · May be fixed by #49643
Labels
kind/bug Categorizes issue or PR as related to a bug. triage/accepted Indicates an issue or PR is ready to be actively worked on.

Comments

@SayakMukhopadhyay
Copy link
Contributor

SayakMukhopadhyay commented Feb 5, 2025

Problem:
Right now localisation keys are not working as expected. This can be seen when attempting to override localisation keys from Docsy. Overriding just doesn't work.

For eg. if I add a key such as [ui_search] in /data/i18n/en/en.toml, it's value is never overriden. It's the value set by Docsy that's shown.

Proposed Solution:
This issue is due to the presence of i18nDir property in hugo.toml. This property forces Hugo to look for translation keys directly in the /data/i18n/en/en.toml and i18n/en/en.toml is completely ignored. This change was made in #43211 which attempted to fix local previewing in Windows as POSIX symlinks were not working at that time. This caused all files in i18n/<language> to not be symlinks, rather contain the relative path to the symlink as text. This is invalid TOML and just removing i18nDir in hugo.toml will once more break Windows local previewing.

But this property is causing overall issues and needs to be removed anyway.

Handling symlinks in Windows
Git can create Windows symlinks when configured properly. See https://github.com/git-for-windows/git/wiki/Symbolic-Links and https://stackoverflow.com/questions/5917249/git-symbolic-links-in-windows. In short, one needs to:

  1. Enable "Developer Mode" in Windows 10/11, gives mklink permissions
  2. Ensure symlinks are enabled in git with (at least) one of:
  • System setting: check the checkbox when installing msysgit

  • Global setting: git config --global core.symlinks true

  • Local setting: git config core.symlinks true

    And not overridden by a lower level config set to false.

Also note, that if you already have a repo checked out, you will need to set the config locally too and switch branches back and forth to get git to realise the change.

See google/docsy#2187 for an earlier issue that was raised and might contain more details.

@SayakMukhopadhyay SayakMukhopadhyay added the kind/bug Categorizes issue or PR as related to a bug. label Feb 5, 2025
@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Feb 5, 2025
@SayakMukhopadhyay SayakMukhopadhyay linked a pull request Feb 5, 2025 that will close this issue
@sftim
Copy link
Contributor

sftim commented Feb 5, 2025

This caused all files in i18n/<language> to not be symlinks, rather contain the relative path to the symlink as text

That wasn't a side effect of #43211; it's more that Windows' symlink support is a bit basic.

@sftim
Copy link
Contributor

sftim commented Feb 5, 2025

My idea: provide a PowerShell script that does roughly the same thing as the Makefile, but for Windows users. A workaround for the symlink handling could be part of this.

@sftim
Copy link
Contributor

sftim commented Feb 5, 2025

We should also revert #43211

@sftim
Copy link
Contributor

sftim commented Feb 5, 2025

/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Feb 5, 2025
@SayakMukhopadhyay
Copy link
Contributor Author

SayakMukhopadhyay commented Feb 5, 2025

My idea: provide a PowerShell script that does roughly the same thing as the Makefile, but for Windows users. A workaround for the symlink handling could be part of this.

Symlinks can be automatically handled in Windows by setting the proper git config parameter so I don't think we need a script, rather we can call it out in contributing docs.

Before we revert #43211, I tried to see what would happen and created the darft PR #49643 to test the netlify build outcome of such a revert. See https://deploy-preview-49643--kubernetes-io-main-staging.netlify.app/

Image
Removing the i18nDir property now causes the translated texts to not be shown at all. I am still working on this trying to figure out where the issue is and I will reply when I know more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants