package web import ( "fmt" "net/http" "net/http/httptest" "strings" "testing" "gitea.mynodes.xyz/ilker/llmgw/internal/store" ) // A Turkish page says the store's errors, percentages and moments the // Turkish way, and a stale form plainly. func TestATurkishPageSpeaksTurkishToTheEnd(t *testing.T) { tr, en := langByCode("tr"), langByCode("en") wrapped := fmt.Errorf("org Acme: %w", store.ErrNotEmpty) if got := tr.Err(wrapped); !strings.Contains(got, "boş değil") { t.Errorf("a wrapped store error in Turkish: %q", got) } if got := en.Err(store.ErrNotFound); !strings.Contains(got, "not there") { t.Errorf("in English: %q", got) } if got := tr.Pct(93, 0); got != "%93" { t.Errorf("Turkish percent %q", got) } if got := en.Pct(93.5, 1); got != "93.5%" { t.Errorf("English percent %q", got) } stamp := tr.funcs()["stamp"].(func(string) string) if got := stamp("2026-10-21T08:05:00Z"); got != "21.10.2026 08:05 UTC" { t.Errorf("a Turkish moment %q", got) } rec := httptest.NewRecorder() req := httptest.NewRequest(http.MethodPost, "/x", nil) req.Header.Set("Accept-Language", "tr") badForm(rec, req) if rec.Code != http.StatusBadRequest || !strings.Contains(rec.Body.String(), "form süresi") { t.Errorf("a stale form in Turkish: %d %q", rec.Code, rec.Body.String()) } }