refactor(i18n): enrich service state snapshot
All checks were successful
Security Scan / security (push) Successful in 12s
Test / test (push) Successful in 2m31s

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Virgil 2026-04-02 13:02:28 +00:00
parent 852b11fda5
commit 730b6166a1
2 changed files with 15 additions and 1 deletions

View file

@ -253,6 +253,7 @@ func TestServiceStateString(t *testing.T) {
"mode=",
"available=",
"handlers=",
"LabelHandler",
} {
if !strings.Contains(got, want) {
t.Fatalf("ServiceState.String() = %q, want substring %q", got, want)

View file

@ -25,8 +25,20 @@ func (s ServiceState) String() string {
if len(s.AvailableLanguages) > 0 {
langs = "[" + core.Join(", ", s.AvailableLanguages...) + "]"
}
handlers := "[]"
if len(s.Handlers) > 0 {
names := make([]string, 0, len(s.Handlers))
for _, handler := range s.Handlers {
if handler == nil {
names = append(names, "<nil>")
continue
}
names = append(names, core.Sprintf("%T", handler))
}
handlers = "[" + core.Join(", ", names...) + "]"
}
return core.Sprintf(
"ServiceState{language=%q fallback=%q mode=%s formality=%s location=%q direction=%s rtl=%t debug=%t available=%s handlers=%d}",
"ServiceState{language=%q fallback=%q mode=%s formality=%s location=%q direction=%s rtl=%t debug=%t available=%s handlers=%d types=%s}",
s.Language,
s.Fallback,
s.Mode,
@ -37,6 +49,7 @@ func (s ServiceState) String() string {
s.Debug,
langs,
len(s.Handlers),
handlers,
)
}