Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

zipErrorMessages.ts

25 lines1.2 KB

1import { mFallback, msg } from "gt-i18n";
2import type { M } from "gt-i18n";
3​
4import type { ZipErrorCode } from "./zipError.ts";
5​
6/** Translatable text for each `ZipError` code. Keep it out of worker imports. */
7export const ZIP_ERROR_MESSAGES: Record<ZipErrorCode, string> = {
8 "file-too-large": msg("Preview limited to files under 50 MB."),
9 "archive-too-many-entries": msg("This archive contains more than 2,048 entries."),
10 "archive-path-too-long": msg("An archive path is too long to preview."),
11 "archive-expanded-too-large": msg(
12 "The expanded archive exceeds the preview size or compression ratio limit.",
13 ),
14 "password-required": msg("This file requires a password."),
15 "password-incorrect": msg("Incorrect password. Try again."),
16 "encryption-unsupported": msg("This file uses encryption that the preview cannot open."),
17 "zip-unreadable": msg("This is not a readable ZIP archive."),
18 "zip64-unsupported": msg("Unsupported ZIP64 directory."),
19 "zip64-damaged": msg("This ZIP64 directory is too large or damaged."),
20 "zip-directory-damaged": msg("This ZIP directory is damaged."),
21};
22​
23export function zipErrorText(code: ZipErrorCode, resolve: M = mFallback): string {
24 return resolve(ZIP_ERROR_MESSAGES[code]);