Add react i18next to console

Signed-off-by: Jonathan <contact@grafikart.fr>
This commit is contained in:
Jonathan
2026-07-21 16:09:41 +02:00
committed by Bryan Frimin
parent 1b7b2594eb
commit a7ff5f07bc
420 changed files with 10251 additions and 6825 deletions

View File

@@ -0,0 +1,50 @@
// Copyright (c) 2025-2026 Probo Inc <hello@probo.com>.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
import { describe, expect, it } from "vitest";
import { fileSize, humanizeSeconds } from "./index";
describe("fileSize", () => {
it("formats byte counts with translated units", () => {
const t = (key: string) => key.replace("size.", "");
expect(fileSize(4911, t)).toBe("4.8 KB");
expect(fileSize(20, t)).toBe("20 B");
});
});
describe("humanizeSeconds", () => {
const t = (key: string, options?: { count?: number }) => {
const unit = key.replace("duration.", "");
if (unit === "session" || unit === "persistent") return unit;
return options?.count === 1 ? unit.slice(0, -1) : unit;
};
it("formats durations with translated plural units", () => {
expect(humanizeSeconds(4570, t)).toBe("1 hour, 16 minutes, 10 seconds");
expect(humanizeSeconds(120, t)).toBe("2 minutes");
});
it("formats trackers without a max age as session or persistent", () => {
expect(humanizeSeconds(null, t)).toBe("session");
expect(humanizeSeconds(0, t, "LOCAL_STORAGE")).toBe("persistent");
});
});