google / google/comprehensive-rust

Link to correct line when editing a translation

Open
#1,075 6 comments 0 reactions 0 assignees View on GitHub
enhancement good first issue help wanted
Dominant language
Rust
Stars
33.4k
Forks
2.1k
Avg merge
1d 3h
Merged PRs (30d)
10

Description

On a whim, I tried adding a `#Lnnn` fragment to a URL which opens the GitHub code editor... and it works! Check out [line 3456 of the Korean translation](https://github.com/google/comprehensive-rust/edit/main/po/ko.po#L3456).

With this, we are able to create useful links on the published pages for the translations. Currently, we simply link to the `xx.po` file, but we should instead link to the first message of each page. We could do so in a few different ways:

- We could post-process the HTML. Something like loading each page, find the first paragraph, look it up in the `xx.po` file, get the line number, inject the line number into the link on the page.
- We could use the GitHub API to download the file on demand when clicking the edit link. We would then search like above and send people to the right spot in the editor. The PO files are 500-800 KB in size, so that might be a little heavy-handed.

We could go with a hybrid version: generate and publish a small `xx.json` file with the correct line number for every path. Then download this file when clicking the link. That ought to be fairly simple since it's easy to load JSON files from JavaScript, and it will be pretty simple to produce this file when we publish the course.

Implementing this would drastically improve the editing experience for our translators.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.