Skip to content

web: localize Pierre diff and file tree text - #8435

Merged
unknwon merged 6 commits into
mainfrom
jc/pierre-labels-patch
Nov 11, 2026
Merged

unknwon merged 6 commits into
mainfrom
jc/pierre-labels-patch

Conversation

@unknwon

@unknwon unknwon commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

Describe the pull request

Pierre's diff view and file tree render their own English text inside shadow roots. This PR localizes that text through the upstream APIs, instead of rewriting the DOM after each render.

  • Diffs. Upgrades @pierre/diffs from 1.6.4 to 1.7.0-beta.2, which adds a package-wide i18n store ([diffs] Add a labels option for localizing diff text pierrecomputer/pierre#1271). lib/i18n.ts fills it once at startup from the INI-backed locale. That covers "N unmodified lines" (as an ICU plural built from the existing keys), "Expand all" on large collapsed regions, and "No newline at end of file". The text is correct on first paint. A translation that Pierre's ICU parser rejects is logged, and the diff falls back to English instead of failing app startup.
  • File tree. Upgrades @pierre/trees from 1.0.0-beta.6 to 1.0.0 and passes its labels option ([trees] Add a labels option for localizing tree text pierrecomputer/pierre#1272). This localizes the search placeholder, the added, deleted, modified, and renamed status tooltips, and the "contains changed files" tooltip on directories. None of these were localized before.
  • Removes two workarounds.
  • Locale changes always regenerate the JSON. web:build and web:lint now list conf/locale/locale_*.ini and scripts/extract-locales.mjs as inputs. Before, an INI-only change could hit moon's cache and leave src/locales/*.json stale.
  • New en-US keys: repo.diff.expand_all, repo.diff.file_added, repo.diff.file_deleted, repo.diff.file_modified, repo.diff.file_renamed, repo.diff.contains_changed_files. The tree search placeholder reuses repo.search_files.
  • Diffs moves to a beta. 1.7 rewrites rendering on a shared incremental DOM renderer. No other Gogs code changes were needed, and every data-* attribute the diff CSS targets is still emitted.

Link to the issue: n/a

Checklist

  • I agree to follow the Code of Conduct by submitting this pull request.
  • I have read and acknowledge the Contributing guide.
  • I have added test cases to cover the new code or have provided the test plan. (if applicable)
  • I have added an entry to CHANGELOG. (if applicable)

Test plan

  1. moon run web:build and moon run web:lint pass.
  2. Rendered in Node: @pierre/[email protected] through preloadFileDiff shows English by default and only the translated text after i18n.set(), with the singular and plural forms selected correctly. @pierre/[email protected] through preloadFileTree emits the custom labels and falls back to English per label.
  3. Open a commit diff page and confirm highlighting, inline word diffs, unified and split views, hunk expansion, collapsing files, in-page search, and the file tree all work as before on the 1.7 renderer.
  4. In the file tree, search for a file and click a match. Confirm the search stays open with the query. Click outside the tree and confirm it closes.
  5. With ?i18n_debug=1, confirm that the separator count, "Expand all" on a gap over 100 lines, "No newline at end of file", the tree search placeholder, and the tree status tooltips all show their keys.
  6. Run moon run web:lint twice so the second run is cached. Change only a value in conf/locale/locale_en-US.ini and run it again. The task reruns and web/src/locales/en-US.json picks up the change.

Base automatically changed from jc/pierre-upgrade to main November 7, 2026 18:00
@unknwon
unknwon force-pushed the jc/pierre-labels-patch branch from 379b2fa to b1f01ce Compare November 7, 2026 18:11
@unknwon
unknwon requested a max review from Copilot November 7, 2026 18:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Both Docker webbuilder stages omit patches/, leaving registered patch files missing and causing both image builds to fail during pnpm install --frozen-lockfile.

1 open issue
1 file not reviewed
  • pnpm-lock.yaml: Generated file
What changed in this PR

This PR localizes Pierre-rendered diff and file tree text directly in the React frontend, replacing post-render shadow DOM rewriting.

Changes:

  • Adds dependency patches exposing label options for @pierre/diffs and @pierre/trees.
  • Passes memoized translations to diff and tree renderers, including tree label updates.
  • Adds English locale keys and records both patches in pnpm configuration and the lockfile.
File Description
web/​src/​pages/​repo/​Commit.tsx Replaces the observer workaround with localized diff options.
web/​src/​locales/​en-US.json Adds generated English diff and tree labels.
web/​src/​components/​DiffFileTree.tsx Supplies translated search and status labels and refreshes them when changed.
web/​scripts/​extract-locales.mjs Includes the new locale keys in extraction.
pnpm-workspace.yaml Registers both dependency patches.
pnpm-lock.yaml Records patch hashes and patched dependency resolutions.
patches/​@[email protected] Adds tree label options and runtime updates.
patches/​@[email protected] Adds label options to diff rendering and CodeView.
conf/​locale/​locale_en-US.ini Defines the new source English strings.

Review effort: Max

Comment thread pnpm-workspace.yaml Resolved
@unknwon unknwon changed the title web: localize Pierre diff and file tree text through patched labels options web: localize Pierre diff and file tree text Nov 8, 2026
@unknwon
unknwon force-pushed the jc/pierre-labels-patch branch from 428b3ed to a565dda Compare November 11, 2026 19:52
@unknwon
unknwon merged commit 7fd3f3d into main Nov 11, 2026
6 checks passed
@unknwon
unknwon deleted the jc/pierre-labels-patch branch November 11, 2026 20:17
appthin added a commit to appthin/gogs-plus that referenced this pull request Nov 12, 2026
Brings in the 0.14.4 security and bug fixes (gogs#8439, gogs#8472, gogs#8478, gogs#8480-gogs#8484,
gogs#8486, gogs#8488), the Highlights-based diff highlighter for the web UI (gogs#8492,
gogs#8434, gogs#8435), absolute entrypoint paths for the SPA shell (gogs#8447), Docker
workflow updates (gogs#8463, gogs#8475), and housekeeping.

Fork-specific code is preserved: CodeQL workflow, login bans, sign-in
protection, the -plus release pipeline, and the rewritten README.
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 this pull request may close these issues.

2 participants