[agent/codex:gpt-5.4-mini] Read ~/spec/code/core/go/i18n/RFC.md fully. Find features de... #199
2 changed files with 72 additions and 0 deletions
|
|
@ -213,6 +213,46 @@ func (s *CoreService) Debug() bool {
|
|||
return s.svc.Debug()
|
||||
}
|
||||
|
||||
// AddHandler appends handlers to the wrapped service's chain.
|
||||
func (s *CoreService) AddHandler(handlers ...KeyHandler) {
|
||||
s.svc.AddHandler(handlers...)
|
||||
}
|
||||
|
||||
// SetHandlers replaces the wrapped service's handler chain.
|
||||
func (s *CoreService) SetHandlers(handlers ...KeyHandler) {
|
||||
s.svc.SetHandlers(handlers...)
|
||||
}
|
||||
|
||||
// PrependHandler inserts handlers at the front of the wrapped service's chain.
|
||||
func (s *CoreService) PrependHandler(handlers ...KeyHandler) {
|
||||
s.svc.PrependHandler(handlers...)
|
||||
}
|
||||
|
||||
// ClearHandlers removes all handlers from the wrapped service.
|
||||
func (s *CoreService) ClearHandlers() {
|
||||
s.svc.ClearHandlers()
|
||||
}
|
||||
|
||||
// ResetHandlers restores the wrapped service's default handler chain.
|
||||
func (s *CoreService) ResetHandlers() {
|
||||
s.svc.ResetHandlers()
|
||||
}
|
||||
|
||||
// Handlers returns a copy of the wrapped service's handler chain.
|
||||
func (s *CoreService) Handlers() []KeyHandler {
|
||||
return s.svc.Handlers()
|
||||
}
|
||||
|
||||
// AddLoader loads extra locale data into the wrapped service.
|
||||
func (s *CoreService) AddLoader(loader Loader) error {
|
||||
return s.svc.AddLoader(loader)
|
||||
}
|
||||
|
||||
// LoadFS loads locale data from a filesystem into the wrapped service.
|
||||
func (s *CoreService) LoadFS(fsys fs.FS, dir string) error {
|
||||
return s.svc.LoadFS(fsys, dir)
|
||||
}
|
||||
|
||||
// AvailableLanguages returns the wrapped service languages.
|
||||
func (s *CoreService) AvailableLanguages() []string {
|
||||
return s.svc.AvailableLanguages()
|
||||
|
|
|
|||
|
|
@ -370,6 +370,38 @@ func TestCoreService_DelegatesToWrappedService(t *testing.T) {
|
|||
assert.True(t, coreSvc.Debug())
|
||||
coreSvc.SetDebug(false)
|
||||
assert.False(t, coreSvc.Debug())
|
||||
|
||||
handlers := coreSvc.Handlers()
|
||||
assert.Equal(t, svc.Handlers(), handlers)
|
||||
|
||||
coreSvc.SetHandlers(LabelHandler{})
|
||||
require.Len(t, coreSvc.Handlers(), 1)
|
||||
assert.IsType(t, LabelHandler{}, coreSvc.Handlers()[0])
|
||||
|
||||
coreSvc.AddHandler(ProgressHandler{})
|
||||
require.Len(t, coreSvc.Handlers(), 2)
|
||||
assert.IsType(t, ProgressHandler{}, coreSvc.Handlers()[1])
|
||||
|
||||
coreSvc.PrependHandler(CountHandler{})
|
||||
require.Len(t, coreSvc.Handlers(), 3)
|
||||
assert.IsType(t, CountHandler{}, coreSvc.Handlers()[0])
|
||||
|
||||
coreSvc.ClearHandlers()
|
||||
assert.Empty(t, coreSvc.Handlers())
|
||||
|
||||
coreSvc.ResetHandlers()
|
||||
require.NotEmpty(t, coreSvc.Handlers())
|
||||
assert.IsType(t, LabelHandler{}, coreSvc.Handlers()[0])
|
||||
|
||||
require.NoError(t, coreSvc.AddLoader(NewFSLoader(fstest.MapFS{
|
||||
"locales/en.json": &fstest.MapFile{Data: []byte(`{"core.service.loaded": "loaded"}`)},
|
||||
}, "locales")))
|
||||
assert.Equal(t, "loaded", coreSvc.T("core.service.loaded"))
|
||||
|
||||
require.NoError(t, coreSvc.LoadFS(fstest.MapFS{
|
||||
"locales/en.json": &fstest.MapFile{Data: []byte(`{"core.service.loaded.fs": "loaded via fs"}`)},
|
||||
}, "locales"))
|
||||
assert.Equal(t, "loaded via fs", coreSvc.T("core.service.loaded.fs"))
|
||||
}
|
||||
|
||||
func TestInit_ReDetectsRegisteredLocales(t *testing.T) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue