mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-18 11:56:01 +02:00
i18n(backup): make the restore notes and preview details translatable (#2656)
A German user got a translated modal with "Not present in this backup commit" in
the middle of it. Every tally note and preview caveat was a server-built English
sentence rendered verbatim.
Follows the backup.pathCheck contract already in use one card down in the same
component, deliberately rather than inventing a second convention: the server
sends a `code` plus typed `params` and carries the English along as the
fallback, and the client renders
`t(`...${code}`, { ...params, defaultValue: message })`. The defaultValue arm is
what keeps a newer backend's unfamiliar code readable instead of printing the
raw key — covered by its own test.
Shapes:
- notes: list[str] -> list[GitHubRestoreNote] {code, params, message}. Breaking,
but the field is unreleased in this same PR.
- GitHubRestorePreviewCategory gains detail_code / detail_params; `detail` stays
as the English fallback.
- _CategoryTally.note(code, message, **params), deduped on (code, params) rather
than on the rendered text, so two offline printers both keep their names. The
20-note cap is unchanged.
28 new leaves across 13 locales: 20 notes.* and 8 details.*. `noData` collapses
the four per-category "No X data in this backup" strings into one, since the
category heading already renders beside it. Counts use single-form {{count}} in
the existing "N record(s)" style rather than i18next plural suffixes — nothing in
this block uses _one/_other and the parity script has extra rules for them.
Parity holds at 5737 leaves in all 13 locales.
Deliberately out of scope, and worth saying so rather than leaving it to look
like an oversight: result.message, the commit-picker subject lines and the HTTP
error strings stay English. Those also originate in the provider backends, so
code-ifying them widens the diff well past the restore service.
spoolTagKept is added here with the rest of the locale churn but is not emitted
until the next commit, so the 13-locale change lands once.
This commit is contained in:
@@ -2845,11 +2845,22 @@ export interface GitHubCommitListResponse {
|
||||
commits: GitHubCommitInfo[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Values the server interpolates into a translated note or preview detail.
|
||||
* Kept to strings and numbers on purpose — anything richer would have to be
|
||||
* formatted server-side and could not be translated.
|
||||
*/
|
||||
export type GitHubRestoreParams = Record<string, string | number>;
|
||||
|
||||
export interface GitHubRestorePreviewCategory {
|
||||
category: RestoreCategory;
|
||||
available: boolean;
|
||||
item_count: number;
|
||||
/** English rendering. Used as i18next's defaultValue, never shown on its own. */
|
||||
detail: string | null;
|
||||
/** Key under backup.restoreFromGit.details, or null when there is no caveat. */
|
||||
detail_code: string | null;
|
||||
detail_params: GitHubRestoreParams;
|
||||
}
|
||||
|
||||
export interface GitHubRestorePreview {
|
||||
@@ -2867,11 +2878,26 @@ export interface GitHubRestoreRequest {
|
||||
overwrite_existing?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* One tally note, as a translation code plus its parameters (#2656).
|
||||
*
|
||||
* Same contract as {@link LocalBackupPathCheck} one card down: the server picks
|
||||
* the code and supplies typed params, and the client renders
|
||||
* ``t(`backup.restoreFromGit.notes.${code}`, { ...params, defaultValue: message })``.
|
||||
* A code the client does not know yet falls back to the English `message`
|
||||
* rather than showing the raw key.
|
||||
*/
|
||||
export interface GitHubRestoreNote {
|
||||
code: string;
|
||||
params: GitHubRestoreParams;
|
||||
message: string;
|
||||
}
|
||||
|
||||
export interface GitHubRestoreCategoryResult {
|
||||
restored: number;
|
||||
skipped: number;
|
||||
failed: number;
|
||||
notes: string[];
|
||||
notes: GitHubRestoreNote[];
|
||||
}
|
||||
|
||||
export interface GitHubRestoreResponse {
|
||||
|
||||
Reference in New Issue
Block a user