From a8053b3d77d922b4811ed384150f028ac89bd0f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sat, 25 Jul 2026 05:03:26 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=87=B9=F0=9F=87=B7=20localize=20th?= =?UTF-8?q?e=20settings=20duplicate-entry=20error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - the backend now rejects two settings entries that are the same word apart from Turkish casing (İZİN vs izin); without a mapping a Turkish admin saw "İşlem tamamlanamadı: " - map both the exam_kinds and attendance_statuses strings, EN and TR, with a test pinning the exact backend wording --- src/api/__tests__/client/client.test.ts | 17 +++++++++++++++++ src/api/client/client.ts | 10 ++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/api/__tests__/client/client.test.ts b/src/api/__tests__/client/client.test.ts index 773e2cf..513adf1 100644 --- a/src/api/__tests__/client/client.test.ts +++ b/src/api/__tests__/client/client.test.ts @@ -124,6 +124,23 @@ describe("client", () => { expect(formatApiErrorMessage("forbidden", "tr")).toBe("Bu işlem için yetkin yok."); }); + it("localizes the settings duplicate-entry error (Turkish casing)", () => { + // exact backend strings from settings.rs validate_list — a miss here renders + // "İşlem tamamlanamadı: " to a Turkish admin + const kinds = "exam_kinds: two entries are the same word apart from upper/lower case or Turkish letters — keep only one of them"; + const statuses = + "attendance_statuses: two entries are the same word apart from upper/lower case or Turkish letters — keep only one of them"; + expect(formatApiErrorMessage(kinds, "tr")).toBe( + "İki sınav türü, büyük/küçük harf veya Türkçe harf farkı dışında aynı. Sadece birini bırak.", + ); + expect(formatApiErrorMessage(statuses, "tr")).toBe( + "İki yoklama durumu, büyük/küçük harf veya Türkçe harf farkı dışında aynı. Sadece birini bırak.", + ); + expect(formatApiErrorMessage(kinds, "en")).toBe( + "Two exam kinds are the same word apart from upper/lower case or Turkish letters. Keep only one of them.", + ); + }); + it("localizes slot-overlap conflicts (no half-English fallback)", () => { // exact backend strings (lowercase) must map, not fall through to "İşlem tamamlanamadı: " expect(formatApiErrorMessage("this time overlaps a slot you have already published", "tr")).toBe( diff --git a/src/api/client/client.ts b/src/api/client/client.ts index c803523..375275d 100644 --- a/src/api/client/client.ts +++ b/src/api/client/client.ts @@ -22,6 +22,16 @@ type RequestOptions = { const API_PREFIX = "/api"; const API_ERROR_MESSAGES: Record> = { + // Settings lists reject two entries that fold to the same word — İZİN/izin, + // ÖDEV/odev. Keyed on the whole normalized string, so both fields are listed. + "exam_kinds: two entries are the same word apart from upper/lower case or turkish letters — keep only one of them": { + en: "Two exam kinds are the same word apart from upper/lower case or Turkish letters. Keep only one of them.", + tr: "İki sınav türü, büyük/küçük harf veya Türkçe harf farkı dışında aynı. Sadece birini bırak.", + }, + "attendance_statuses: two entries are the same word apart from upper/lower case or turkish letters — keep only one of them": { + en: "Two attendance statuses are the same word apart from upper/lower case or Turkish letters. Keep only one of them.", + tr: "İki yoklama durumu, büyük/küçük harf veya Türkçe harf farkı dışında aynı. Sadece birini bırak.", + }, "request failed": { en: "Request failed.", tr: "İşlem tamamlanamadı.",