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

Use localization friendly links in English main site. #18403

Closed
tengqm opened this issue Jan 2, 2020 · 37 comments
Closed

Use localization friendly links in English main site. #18403

tengqm opened this issue Jan 2, 2020 · 37 comments
Labels
kind/feature Categorizes issue or PR as related to a new feature. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete.

Comments

@tengqm
Copy link
Contributor

tengqm commented Jan 2, 2020

This is a Feature Request

What would you like to be added

The intra-site links in the English documents are currently plain markdown links, as shown below:

* Learn about [Controllers](/docs/concepts/architecture/controller/)

When pages containing such links are translated into another language, the localization team has to take extra care to handle them or else the links will be missing or pointing to an incorrect location. For example, in the Chinese localization, the above line has to be revised to something like:

* 进一步了解 [控制器](/zh/docs/concepts/architecture/controller/)

We need to revise this links to one of the following formats so that the links can be automatically converted to the correct target:

* Learn about [Controllers]({{< relref "docs/concepts/architecture/controller.md" >}})
* Learn about [Controllers]({{< ref "/docs/concepts/architecture/controller.md" >}})

For English main site and all localization sites, the above links can be correctly converted.

Why is this needed

Taking care of so many links for so many localization, across so many teams is error-prone and boring. Once we have the links on the English main site refactored. All localization teams can simply skip updating the link target.

As a bonus, if a link target doesn't exist in a particular language, Hugo can detect the missing link and report errors during build. So we can detect missing links as early as possible.

Comments

For related experiments, see #18374

@sftim
Copy link
Contributor

sftim commented Jan 2, 2020

💯 this

To be honest, when I started contributing I saw that there were localizations and I assumed that a mechanism similar to this already existed. I was genuinely surprised when I realized that localization teams needed to manually track this kind of detail.

@sftim
Copy link
Contributor

sftim commented Jan 2, 2020

/kind feature
Does /priority important-longterm feel right?

@k8s-ci-robot k8s-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Jan 2, 2020
@tengqm
Copy link
Contributor Author

tengqm commented Jan 2, 2020

No objections wrt priority. :)

@sftim
Copy link
Contributor

sftim commented Jan 2, 2020

/priority important-longterm

@k8s-ci-robot k8s-ci-robot added the priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. label Jan 2, 2020
@kbhawkey
Copy link
Contributor

kbhawkey commented Jan 9, 2020

This is interesting!
Looking at the Hugo docs,
https://gohugo.io/content-management/cross-references/

How does this workk?

{{< relref path="document.md" lang="ja" >}}

@tengqm
Copy link
Contributor Author

tengqm commented Jan 10, 2020

Right, if you explicitly provide a lang param, hugo will try redirect you to the specified localization. One use case, in k8s/website could be that for some content, we want to redirect all anchors to the same language, say English.

@tanjunchen
Copy link
Member

@tengqm
Is it appropriate to add /zh directly in front of it right now?
/cc @yuxiaobo96
thanks your job!

@tanjunchen
Copy link
Member

@sftim @tengqm
Is there any progress on this matter?

@yuxiaobo96
Copy link
Contributor

I think the modification proposed by tengqm is better.

@tengqm
Copy link
Contributor Author

tengqm commented Jan 10, 2020

@tanjunchen No progress yet. If the proposed approach makes sense, we may need to revise the English site as early as possible.

@tanjunchen
Copy link
Member

@tanjunchen No progress yet. If the proposed approach makes sense, we may need to revise the English site as early as possible.

done

@Colstuwjx
Copy link
Contributor

Inspired by @tengqm PR #18374 experiment, I have been proposed another PR #18678 for solving this issue.

For ref and relref, I did some research, see hugo 2637, there is no builtin function do check existence ONLY, and I found lang.Merge, but it seems not addressing this issue, see hugo 5612.

For these reasons, I think customized shortcode should be better, and PR #18678 is my answer.
Many thanks to @tengqm great job.

@sftim
Copy link
Contributor

sftim commented Jan 26, 2020

Sort of related: PR #18871.

@remyleone
Copy link
Contributor

@feloy @rekcah78

@tanjunchen
Copy link
Member

How about this issue now ? see #18929
They add ja in front of the path.
Is it currently possible to implement similar functionality directly by modifying the hugo code.
/cc @tengqm
/cc @Colstuwjx

@tengqm
Copy link
Contributor Author

tengqm commented Mar 7, 2020

@tanjunchen It is not gonna be a trivial change. I'm not a big fan of adding/modifying hugo code in this repo.

@Colstuwjx
Copy link
Contributor

@tengqm Do you have any idea about solving this issue?

I think it should be a common issue for multilingual site, and we may need to make a conclusion about how to fix this issue at first, and then try to propose a PR for fixing it, here are some considerations in my mind:

We already have multilingual configurations, such as supported languages and their weight, content dir, language alternatives etc, if we could add something for configuring this link convert, for example like adding configuration makeRefAddLangPrefixByDefault=true.

If it's been set true, we could make hugo adding the language prefix by current dir language and its alternative language, therefore, we didn't need to handle this job by manually anymore...

If someone didn't prepare the translation placeholder for the ref, hugo should try to make the ref link fallback to the alternative language, and if it still fails, hugo should panic and throw errors, just like the shortcode ref and relref did.

What do you think about this solution? Or it's welcome if you have another better and workable solution. If we could make a conclusion, and it needs do some job with hugo upstream, I'm ready to do this.

Thanks.

@tengqm
Copy link
Contributor Author

tengqm commented Mar 7, 2020

The makeRefAddLangPrefixByDefault=true suggestion sounds good at fist glance. However, from Hugo developer's perspective, it may not be a priority since there are already existing facility to achieve the same goal. We may even conclude that our current way of codifying intra-site links are wrong. We SHOULD have used the localization friendly way to do this.

@Colstuwjx
Copy link
Contributor

Colstuwjx commented Mar 7, 2020

We SHOULD have used the localization friendly way to do this.

Yes, I was also wondering about this. I don't have any idea about which is the right way to do this, so I leave a comment on hugo repo, maybe hugo dev could give us some suggestions.

@tanjunchen
Copy link
Member

We SHOULD have used the localization friendly way to do this.

+1
@Colstuwjx I have no good idea.

tengqm added a commit to tengqm/website that referenced this issue Mar 7, 2020
This attempts to improve intra-site links so that the links can be
automatically translated to localized versions.

xref: kubernetes#18403

This PR is about the concepts/architecture and
concepts/cluster-administration directories.
tengqm added a commit to tengqm/website that referenced this issue Mar 7, 2020
This attempts to improve intra-site links so that the links can be
automatically translated to localized versions.

xref: kubernetes#18403

This PR is about the concepts/architecture and
concepts/cluster-administration directories.
tengqm added a commit to tengqm/website that referenced this issue Mar 8, 2020
This attempts to improve intra-site links so that the links can be
automatically translated to localized versions.

xref: kubernetes#18403

This PR is about the concepts/architecture and
concepts/cluster-administration directories.
tengqm added a commit to tengqm/website that referenced this issue Mar 8, 2020
This attempts to improve intra-site links so that the links can be
automatically translated to localized versions.

xref: kubernetes#18403

This PR is about the concepts/architecture and
concepts/cluster-administration directories.
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jul 5, 2020
@tengqm
Copy link
Contributor Author

tengqm commented Jul 5, 2020

still relevant.
/remove-lifecycle rotten

@k8s-ci-robot k8s-ci-robot removed the lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. label Jul 5, 2020
@irvifa
Copy link
Member

irvifa commented Jul 10, 2020

@tengqm would you like to help us for this issue? I was wondering what else needed besides the config itself.

@tengqm
Copy link
Contributor Author

tengqm commented Jul 10, 2020

@irvifa Please check PR #19526 for the proposed changes.

@sftim
Copy link
Contributor

sftim commented Jul 10, 2020

My number 1 favorite approach would be for a localization team to write something like:

* 进一步了解 [控制器](/docs/concepts/architecture/controller/)

and for the generated HTML to link to https://kubernetes.io/zh/docs/concepts/architecture/controller/ (or whatever language code is appropriate.

If Hugo can't yet do this, it might even be feasible to look into tweaking Hugo itself.

@sftim sftim closed this as completed Jul 10, 2020
@sftim
Copy link
Contributor

sftim commented Jul 10, 2020

/reopen

Oops. Misclick.

@k8s-ci-robot
Copy link
Contributor

@sftim: Reopened this issue.

In response to this:

/reopen

Oops. Misclick.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot reopened this Jul 10, 2020
tengqm added a commit to tengqm/website that referenced this issue Jul 11, 2020
This attempts to improve intra-site links so that the links can be
automatically translated to localized versions.

xref: kubernetes#18403

This PR is about the concepts/architecture and
concepts/cluster-administration directories.
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 8, 2020
@irvifa
Copy link
Member

irvifa commented Oct 8, 2020

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 8, 2020
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 6, 2021
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Feb 5, 2021
@fejta-bot
Copy link

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-contributor-experience at kubernetes/community.
/close

@k8s-ci-robot
Copy link
Contributor

@fejta-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-contributor-experience at kubernetes/community.
/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@Andygol
Copy link
Contributor

Andygol commented May 14, 2024

I would like to /reopen this ticket in light of Hugo's ability to render links via https://gohugo.io/render-hooks/links/. This option can be used to implicitly add a language prefix to links. Thus, all valid Markdown links [text](/docs/…) in the text can receive a language prefix if there is a localized document.

Any advice and suggestions are welcome 🙏

PS. My WIP is here Andygol#160 🚧

@Andygol
Copy link
Contributor

Andygol commented May 14, 2024

@sftim 🛎️ ☝️

@sftim
Copy link
Contributor

sftim commented May 14, 2024

Ack. I've seen the message @Andygol.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete.
Projects
None yet
Development

Successfully merging a pull request may close this issue.