From 0e01e9f894baf41d92cceecab611f9148e22a86b Mon Sep 17 00:00:00 2001 From: Virgil Date: Thu, 2 Apr 2026 14:16:49 +0000 Subject: [PATCH] refactor(i18n): shorten handler names in state snapshots Co-Authored-By: Virgil --- state.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/state.go b/state.go index 4dbc9ae..018fe9f 100644 --- a/state.go +++ b/state.go @@ -1,6 +1,8 @@ package i18n import ( + "strings" + "dappco.re/go/core" ) @@ -82,7 +84,7 @@ func (s ServiceState) String() string { names = append(names, "") continue } - names = append(names, core.Sprintf("%T", handler)) + names = append(names, shortHandlerTypeName(handler)) } handlers = "[" + core.Join(", ", names...) + "]" } @@ -104,6 +106,14 @@ func (s ServiceState) String() string { ) } +func shortHandlerTypeName(handler KeyHandler) string { + name := core.Sprintf("%T", handler) + if idx := strings.LastIndex(name, "."); idx >= 0 { + name = name[idx+1:] + } + return strings.TrimPrefix(name, "*") +} + func (s *Service) State() ServiceState { if s == nil { return defaultServiceStateSnapshot()