Repository navigation
Templates: Introduced an optional add-on with GitHub's wording in Forgejo's languages - #185
Merged
Merged
Conversation
5 of 8 tasks
Forgejo reads a custom locale file instead of its own, never on top of it, so the theme could not add GitHub's wording without replacing Forgejo's translations and any an admin customised. The theme now keeps its own phrases in locales/<lang>.json for every language Forgejo enables by default, and the build compiles them with Forgejo's plural rules into the template theme/phrase. A template asks for a phrase with Forgejo's text as the fallback. The wording is optional. The templates pack's theme/phrase prints only Forgejo's text, so the pack keeps Forgejo's translations. The compiled template ships alone in theme-github-wording.tar.gz, which admins extract over the pack for GitHub's wording; a reader in a language without theme phrases still sees Forgejo's. The local preview applies it unless FORGEJO_PREVIEW_GITHUB_WORDING=false. The first phrases are the merge box's: check titles, counts and groups, the clean, conflict and draft rows, and the merged and closed boxes. A test keeps every language complete, with its plural forms and the English placeholders. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
whereareiam
force-pushed
the
feat/theme-phrases
branch
from
November 14, 2026 14:50
780d389 to
69445a8
Compare
6 of 8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The theme can now show GitHub's wording where Forgejo has no translation of its own, as an optional add-on, without touching Forgejo's translations. By default nothing changes: the templates keep Forgejo's wording.
Why not Forgejo's locale files: Forgejo reads a custom locale file instead of its own, never on top of it (
options.Localereturns the first layer that has the file). Adding keys that way would replace all of Forgejo's translations for that language, and any an admin customised.How it works: the theme's phrases live in
locales/<lang>.json, one file per language, as a string or one string per plural form. The build compiles them with Forgejo's plural rule for each language into the templatetheme/phrase(scripts/phrases.ts). A template asks for a phrase with Forgejo's own text as the fallback:Optional for admins:
theme-github-templates.tar.gzships atheme/phrasethat prints only the fallback, so the templates show Forgejo's translations. The newtheme-github-wording.tar.gzholds just the compiledtheme/phrase; extracting it into<forgejo-data>after the templates switches to GitHub's wording. Since it replaces a file of the templates, it is extracted again after each templates update (README step 3).No English in other languages: with the add-on, a reader whose language has no theme phrases (one an admin adds beyond Forgejo's defaults) still sees Forgejo's text.
Languages: all 31 Forgejo enables by default. The wording follows each language's existing Forgejo terms (for example Prüfung, проверка, 合并请求). The translations are mine, not GitHub's, so native speakers may want to refine them later.
Local preview: applies the add-on, so the preview can be compared with GitHub;
FORGEJO_PREVIEW_GITHUB_WORDING=false bun dev:forgejo:syncshows the templates without it.Checks: a test fails when a language misses a key, a plural form its rule needs, or a placeholder the English phrase uses, checks the plural rules against Forgejo's, and that the templates pack keeps Forgejo's wording.
The first phrases are the merge box's, used by #184. This PR alone changes nothing visible.
Before and after
#184's merge box, with the templates alone and with the wording add-on, at 1280px in the dark theme.
theme-github-wording.tar.gzRelease notes
Area: Descriptionwith a listed areaBranches: Fixed ...feature,change,bug,dependencies, orskip-changelogbugonly for a bug that shipped in a release; a fix for a bug that only existed ondevisskip-changelogmajoradded when admins must act on upgrade, for example a new minimum Forgejo version.github/release-notes.md, if admins need themChecks
bun check,bun vitest(709 tests) and prettier pass. The release packaging builds both archives (theme-github-wording.tar.gzholds onlytemplates/theme/phrase.tmpl). README and ARCHITECTURE.md describe the add-on.🤖 Generated with Claude Code