feat(i18n): backport end-user German UI from Onyx PR #12558 as overlay
Temporary multi-language support until Onyx ships official i18n (ETA Q4'26/Q1'27). Backports PR #12558 (react-i18next; end-user UI only, Admin stays English) as a config-driven overlay so the official source stays intact and upgrades stay easy. - branding/i18n/end-user-i18n.patch: the PR's 70-file change set, pinned to its exact base commit (727e096d) so it applies with zero conflicts. - branding.config.json: pin upstream to 727e096d; add i18n block (enabled, patch, baseCommit, defaultLanguage=de, rebrandLocales). - apply-branding.mjs: step 0 git-applies the patch BEFORE the string codemod; the codemod then rebrands Onyx->AIDO inside every locale dict (de/en/es/fr/pt). Idempotent; fails loudly if the checkout isn't at i18n.baseCommit. - README: 'German UI / i18n (temporary)' section — how to edit translations, add languages, and retire the overlay when official i18n lands. Verified: patch applies cleanly on a fresh pinned checkout; `make apply` runs green (198 code + 376 locale replacements across 5 languages); i18n deps resolve. Fill/refine German in web/public/locales/de/common.json (PR ships a full draft).
This commit is contained in:
parent
1e55297ce9
commit
1f2d637263
4 changed files with 17189 additions and 2 deletions
36
README.md
36
README.md
|
|
@ -157,6 +157,42 @@ cached files. To use brand-new files, drop them into `branding/assets/` (matchin
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## German UI / i18n (temporary)
|
||||||
|
|
||||||
|
Onyx has no released multi-language support yet (official ETA Q4 2026 / Q1 2027). As
|
||||||
|
a stop-gap, this overlay backports Onyx's own end-user i18n PR
|
||||||
|
([#12558](https://github.com/onyx-dot-app/onyx/pull/12558)) — **react-i18next**, with a
|
||||||
|
language switcher under Settings → Appearance and **instant** switching. It covers the
|
||||||
|
**end-user UI only**; the Admin panel stays English (that's the PR's own scope).
|
||||||
|
|
||||||
|
It's wired into the overlay, config-driven from `branding.config.json → i18n`:
|
||||||
|
|
||||||
|
- `make apply` `git apply`s `branding/i18n/end-user-i18n.patch` onto the pinned checkout
|
||||||
|
**before** the branding codemod, then rebrands `Onyx`→`AIDO` inside every bundled
|
||||||
|
dictionary (`web/public/locales/{de,en,es,fr,pt}/common.json`).
|
||||||
|
- Because the patch is pinned to its exact base commit
|
||||||
|
(`i18n.baseCommit == upstream.pinnedCommit`), it applies with **zero conflicts**.
|
||||||
|
|
||||||
|
### Editing the German translations
|
||||||
|
|
||||||
|
Fill in / refine `web/public/locales/de/common.json` (the PR already ships a full German
|
||||||
|
draft). Keys are grouped by area (`chat`, `sidebar`, `auth`, `onboarding`, …). Then
|
||||||
|
`make apply && make build && make restart`. Add another language by dropping in a new
|
||||||
|
`web/public/locales/<lang>/common.json`.
|
||||||
|
|
||||||
|
### Retiring it (when official i18n ships)
|
||||||
|
|
||||||
|
Set `i18n.enabled: false` in `branding.config.json`, bump `upstream.pinnedCommit`
|
||||||
|
forward, and re-run `make setup && make apply`. Your `de/common.json` carries over to the
|
||||||
|
official feature, so migration is essentially free.
|
||||||
|
|
||||||
|
> **Upgrade note:** this is a large feature patch pinned to one commit. Moving to a much
|
||||||
|
> newer Onyx before official i18n lands needs a re-sync of the patch (regenerate it
|
||||||
|
> against the new base). `make apply` fails loudly with a clear message if the checkout
|
||||||
|
> isn't at `i18n.baseCommit`, so it never applies half-way.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Upgrading Onyx
|
## Upgrading Onyx
|
||||||
|
|
||||||
Because we don't fork, upgrading is mechanical:
|
Because we don't fork, upgrading is mechanical:
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
import { readFile, writeFile, copyFile, mkdir, readdir, stat } from "node:fs/promises";
|
import { readFile, writeFile, copyFile, mkdir, readdir, stat } from "node:fs/promises";
|
||||||
import { existsSync } from "node:fs";
|
import { existsSync } from "node:fs";
|
||||||
import { fileURLToPath } from "node:url";
|
import { fileURLToPath } from "node:url";
|
||||||
|
import { execFileSync } from "node:child_process";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
|
|
||||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||||
|
|
@ -50,6 +51,34 @@ if (!existsSync(WEB)) {
|
||||||
log(`${c.bold}Livtec white-label → ${CONFIG.brand.name}${c.reset} ${c.gray}(${DRY ? "dry-run" : "apply"}${NO_FETCH ? ", no-fetch" : ""})${c.reset}`);
|
log(`${c.bold}Livtec white-label → ${CONFIG.brand.name}${c.reset} ${c.gray}(${DRY ? "dry-run" : "apply"}${NO_FETCH ? ", no-fetch" : ""})${c.reset}`);
|
||||||
log(`${c.gray}web source: ${WEB}${c.reset}`);
|
log(`${c.gray}web source: ${WEB}${c.reset}`);
|
||||||
|
|
||||||
|
// ── 0. End-user i18n backport (temporary, until official Onyx i18n) ──────────
|
||||||
|
// Applies PR #12558's react-i18next changes onto the pinned checkout. MUST run
|
||||||
|
// before the string codemod so the patch's context lines still match the clean
|
||||||
|
// upstream source; the codemod then rebrands Onyx->AIDO inside the locale JSONs.
|
||||||
|
// Requires the checkout to be at i18n.baseCommit (== upstream.pinnedCommit).
|
||||||
|
if (CONFIG.i18n && CONFIG.i18n.enabled) {
|
||||||
|
step("0/4 End-user i18n (backport of PR #12558)");
|
||||||
|
const patchPath = path.join(ROOT, CONFIG.i18n.patch);
|
||||||
|
if (!existsSync(patchPath)) {
|
||||||
|
warn(`i18n patch not found at ${patchPath} — skipping`);
|
||||||
|
} else {
|
||||||
|
const gitApply = (extra) => execFileSync("git", ["apply", "-p1", ...extra, patchPath], { cwd: ROOT, stdio: "pipe" });
|
||||||
|
let already = false, ok2 = true;
|
||||||
|
try { gitApply(["--check"]); }
|
||||||
|
catch {
|
||||||
|
try { gitApply(["--reverse", "--check"]); already = true; }
|
||||||
|
catch { ok2 = false; }
|
||||||
|
}
|
||||||
|
if (!ok2) {
|
||||||
|
console.error(`${c.red}✗ i18n patch does not apply. The checkout must be at i18n.baseCommit (${CONFIG.i18n.baseCommit}). Run \`make setup\` (pinnedCommit is set to that commit), or set i18n.enabled=false.${c.reset}`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
if (already) ok("i18n patch already applied — skipping");
|
||||||
|
else if (DRY) ok("i18n patch applies cleanly (dry-run, not written)");
|
||||||
|
else { gitApply([]); ok(`applied i18n patch — react-i18next, user UI only (Admin stays English); default language ${CONFIG.i18n.defaultLanguage}`); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ── 1. Assets: fetch brand images, repoint favicon ──────────────────────────
|
// ── 1. Assets: fetch brand images, repoint favicon ──────────────────────────
|
||||||
step("1/4 Assets");
|
step("1/4 Assets");
|
||||||
if (!DRY) await mkdir(PUBLIC_BRANDING, { recursive: true });
|
if (!DRY) await mkdir(PUBLIC_BRANDING, { recursive: true });
|
||||||
|
|
@ -285,6 +314,36 @@ for await (const file of walk(SRC)) {
|
||||||
}
|
}
|
||||||
ok(`${totalReplacements} replacement(s) across ${filesChanged} file(s)`);
|
ok(`${totalReplacements} replacement(s) across ${filesChanged} file(s)`);
|
||||||
|
|
||||||
|
// 3c. Rebrand the bundled i18n dictionaries (Onyx->AIDO in every language) so the
|
||||||
|
// translated UI is branded too. Only when the i18n backport is active.
|
||||||
|
if (CONFIG.i18n && CONFIG.i18n.enabled && CONFIG.i18n.rebrandLocales) {
|
||||||
|
const LOCALES = path.join(PUBLIC, "locales");
|
||||||
|
if (existsSync(LOCALES)) {
|
||||||
|
let locN = 0, locFiles = 0;
|
||||||
|
async function* walkJson(d) {
|
||||||
|
for (const e of await readdir(d, { withFileTypes: true })) {
|
||||||
|
const p = path.join(d, e.name);
|
||||||
|
if (e.isDirectory()) yield* walkJson(p);
|
||||||
|
else if (e.name.endsWith(".json")) yield p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for await (const file of walkJson(LOCALES)) {
|
||||||
|
let s = await readFile(file, "utf8"); let m = 0;
|
||||||
|
for (const [from, to] of literals) {
|
||||||
|
if (s.includes(from)) { const parts = s.split(from); m += parts.length - 1; s = parts.join(to); }
|
||||||
|
}
|
||||||
|
for (const [from, to] of wordPairs) {
|
||||||
|
const re = new RegExp(`\\b${from.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\b`, "g");
|
||||||
|
s = s.replace(re, () => { m++; return to; });
|
||||||
|
}
|
||||||
|
if (m > 0) { if (!DRY) await writeFile(file, s); locN += m; locFiles++; }
|
||||||
|
}
|
||||||
|
ok(`rebranded i18n dictionaries: ${locN} replacement(s) across ${locFiles} locale file(s)`);
|
||||||
|
} else {
|
||||||
|
warn("i18n enabled but no public/locales dir found (patch may not have applied)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ── 4. Summary ──────────────────────────────────────────────────────────────
|
// ── 4. Summary ──────────────────────────────────────────────────────────────
|
||||||
step("4/4 Done");
|
step("4/4 Done");
|
||||||
log(`${c.green}White-label applied for ${c.bold}${CONFIG.brand.name}${c.reset}${c.green} (${CONFIG.brand.legalName}).${c.reset}`);
|
log(`${c.green}White-label applied for ${c.bold}${CONFIG.brand.name}${c.reset}${c.green} (${CONFIG.brand.legalName}).${c.reset}`);
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,21 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
"upstream": {
|
"upstream": {
|
||||||
"$comment": "Pin the exact Onyx commit/tag this overlay was authored against. Bump together with branding.apply when upgrading. Used only for documentation/verification.",
|
"$comment": "Pin the exact Onyx commit/tag this overlay is authored against. Pinned to the base commit of the end-user i18n PR (#12558) so its patch applies cleanly (see i18n below). `make setup` checks out this commit. When Onyx merges official i18n, bump this forward and set i18n.enabled=false.",
|
||||||
"repo": "https://github.com/onyx-dot-app/onyx",
|
"repo": "https://github.com/onyx-dot-app/onyx",
|
||||||
"pinnedCommit": "main",
|
"pinnedCommit": "727e096de85680416bd8d5af0daec3a4f5b407d2",
|
||||||
"webSrcRoot": "web"
|
"webSrcRoot": "web"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"i18n": {
|
||||||
|
"$comment": "TEMPORARY end-user internationalization, backported from Onyx PR #12558 (react-i18next; user UI only, Admin stays English) until the official feature ships. apply-branding.mjs git-applies `patch` onto the pinned checkout BEFORE the branding string codemod, then the codemod also rebrands Onyx->AIDO inside the bundled locale dictionaries. Fill/refine translations in web/public/locales/<lang>/common.json. Set enabled=false to drop it once official i18n lands.",
|
||||||
|
"enabled": true,
|
||||||
|
"patch": "branding/i18n/end-user-i18n.patch",
|
||||||
|
"baseCommit": "727e096de85680416bd8d5af0daec3a4f5b407d2",
|
||||||
|
"defaultLanguage": "de",
|
||||||
|
"rebrandLocales": true
|
||||||
|
},
|
||||||
|
|
||||||
"build": {
|
"build": {
|
||||||
"$comment": "As of 2026-07, Onyx's web Dockerfile bases on Docker Hardened Images (dhi.io/node:*), a paid Docker offering that requires a DHI subscription + `docker login dhi.io` — so `make build` fails with a registry login error for anyone without DHI access. The apply step rewrites those FROM lines to the equivalent PUBLIC Docker Hub node images (Debian 13 / glibc, matching the DHI variant the Dockerfile targets), so the branded image builds with no login. Keys = the dhi.io image ref (the trailing @sha256 digest, if any, is stripped automatically); values = the public replacement. No-op (with a warning) if the DHI lines are absent, so this stays safe across upstream changes.",
|
"$comment": "As of 2026-07, Onyx's web Dockerfile bases on Docker Hardened Images (dhi.io/node:*), a paid Docker offering that requires a DHI subscription + `docker login dhi.io` — so `make build` fails with a registry login error for anyone without DHI access. The apply step rewrites those FROM lines to the equivalent PUBLIC Docker Hub node images (Debian 13 / glibc, matching the DHI variant the Dockerfile targets), so the branded image builds with no login. Keys = the dhi.io image ref (the trailing @sha256 digest, if any, is stripped automatically); values = the public replacement. No-op (with a warning) if the DHI lines are absent, so this stays safe across upstream changes.",
|
||||||
"baseImageReplacements": {
|
"baseImageReplacements": {
|
||||||
|
|
|
||||||
17083
branding/i18n/end-user-i18n.patch
Normal file
17083
branding/i18n/end-user-i18n.patch
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue