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ı.",