Sizes in the interface's language: units and the decimal sign («2,2 ГБ, предел 2,0 ГБ»)
platform::size_text takes the units from the translations ({n} GB …) and
the decimal comma where the language writes one; every size the web version
shows goes through it. chessbase.mjs takes CP_LANG.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
bc104c55b4
commit
b5da315343
3 changed files with 20 additions and 10 deletions
|
|
@ -121,16 +121,25 @@ pub fn storage_free() -> Option<u64> {
|
|||
None
|
||||
}
|
||||
|
||||
/// A size for people: "340 KB", "96 MB", "9.6 GB".
|
||||
/// A size for people in the interface's language: "340 KB", "96 MB", "9.6 GB"
|
||||
/// («9,6 ГБ», «9,6 Go»: its units and its decimal sign).
|
||||
pub fn size_text(bytes: u64) -> String {
|
||||
use crate::i18n::{tr, trf};
|
||||
let b = bytes as f64;
|
||||
if b >= 1e9 {
|
||||
format!("{:.1} GB", b / 1e9)
|
||||
let (n, unit) = if b >= 1e9 {
|
||||
(format!("{:.1}", b / 1e9), "{n} GB")
|
||||
} else if b >= 1e6 {
|
||||
format!("{:.0} MB", b / 1e6)
|
||||
(format!("{:.0}", b / 1e6), "{n} MB")
|
||||
} else {
|
||||
format!("{:.0} KB", (b / 1e3).max(1.0))
|
||||
}
|
||||
(format!("{:.0}", (b / 1e3).max(1.0)), "{n} KB")
|
||||
};
|
||||
// The key's own text where the language writes a decimal point.
|
||||
let n = if tr("decimal comma") == "," {
|
||||
n.replace('.', ",")
|
||||
} else {
|
||||
n
|
||||
};
|
||||
trf(unit, &[("n", &n)])
|
||||
}
|
||||
|
||||
/// A line for the program's log (`chesspenguin.log`; in a browser its console).
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ const read = (name) => s.logs.filter((l) => l.includes(`database read: ${name}`)
|
|||
const cbh = readdirSync(baseDir).find((n) => n.toLowerCase().endsWith('.cbh'));
|
||||
const stem = cbh.slice(0, -4);
|
||||
try {
|
||||
await t.navigate(`${s.base}?lang=en`);
|
||||
await t.navigate(`${s.base}?lang=${process.env.CP_LANG || "en"}`);
|
||||
await started();
|
||||
await sleep(2500);
|
||||
|
||||
|
|
@ -64,7 +64,7 @@ try {
|
|||
}
|
||||
|
||||
// The next visit: Chrome reads the remembered folder's database again by itself.
|
||||
await t.navigate(`${s.base}?lang=en`);
|
||||
await t.navigate(`${s.base}?lang=${process.env.CP_LANG || "en"}`);
|
||||
await started();
|
||||
await sleep(3000);
|
||||
await shot('cb-5-reloaded.png');
|
||||
|
|
|
|||
|
|
@ -299,7 +299,8 @@ Chrome for Testing 156.0.8078.80 (linux64) взят с официального
|
|||
- **Предел — 2 ГБ** по сумме файлов базы, которые читаются (`TOO_BIG`, для ChessBase — `USED`): больше —
|
||||
окно «База слишком большая для браузера (N ГБ, предел 2,0 ГБ). Извините — откройте её в программе для
|
||||
компьютера» со ссылкой «Скачать ChessPenguin для компьютера» (`/<язык>/#download`). Mega Database 2026
|
||||
(≈ 4,7 ГБ всего, читаемых файлов 2,2 ГБ) — отказ.
|
||||
(≈ 4,7 ГБ всего, читаемых файлов 2,2 ГБ) — отказ. Размеры везде — `platform::size_text`: единицы
|
||||
(`{n} GB` → «ГБ», «Go») и десятичный знак (ключ `decimal comma`) по языку интерфейса.
|
||||
- **Память, замер 2026-10-30**: PGN 1,95 ГБ (cp1251, 194 643 партии) открывается — Firefox 64 с, Chrome 60 с;
|
||||
1 ГБ — 32 с. Для этого исправлена `chess_core::repair::detect_letter_substitution`: она декодировала весь
|
||||
текст и собирала `Vec<char>` (×4 размера) — на компьютере лишние гигабайты, в wasm32 переполнение
|
||||
|
|
@ -309,7 +310,7 @@ Chrome for Testing 156.0.8078.80 (linux64) взят с официального
|
|||
этой базы. Откройте её в программе для компьютера» и заводит новый воркер.
|
||||
- **Без служебных путей в текстах**: `platform::files::shown(path)` — имя файла в браузере, путь на
|
||||
компьютере; ошибки чтения в вебе — без пути (`import_error`).
|
||||
- Проверка `apps/web/check/chessbase.mjs <app> <out> <папка небольшой базы> [<папка базы > 2 ГБ>]`:
|
||||
- Проверка `[CP_LANG=ru] apps/web/check/chessbase.mjs <app> <out> <папка небольшой базы> [<папка базы > 2 ГБ>]`:
|
||||
одиночный `.cbh` → окно → папка → база прочитана; все файлы сразу; > 2 ГБ — отказ; в Chrome папка
|
||||
запоминается. Firefox 159 и Chrome for Testing 156 — ok (тестовая база из `pgnFilesforExample/` только
|
||||
локально, в репозиторий не входит).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue