[agent/codex:gpt-5.4-mini] Read ~/spec/code/core/go/i18n/RFC.md fully. Find features de... #195

Merged
Virgil merged 1 commit from agent/read---spec-code-core-go-i18n-rfc-md-ful into dev 2026-04-02 10:09:39 +00:00
2 changed files with 47 additions and 0 deletions

View file

@ -25,8 +25,16 @@ type CoreService struct {
type ServiceOptions struct {
// Language overrides auto-detection (e.g., "en-GB", "de")
Language string
// Fallback sets the fallback language for missing translations.
Fallback string
// Formality sets the default formality level.
Formality Formality
// Location sets the default location context.
Location string
// Mode sets the translation mode (Normal, Strict, Collect)
Mode Mode
// Debug prefixes translated output with the message key.
Debug bool
// ExtraFS loads additional translation files on top of the embedded defaults.
// Each entry is an fs.FS + directory path within it.
ExtraFS []FSSource
@ -67,8 +75,18 @@ func NewCoreService(opts ServiceOptions) func(*core.Core) (any, error) {
return nil, langErr
}
}
if opts.Fallback != "" {
svc.SetFallback(opts.Fallback)
}
if opts.Formality != FormalityNeutral {
svc.SetFormality(opts.Formality)
}
if opts.Location != "" {
svc.SetLocation(opts.Location)
}
svc.SetMode(opts.Mode)
svc.SetDebug(opts.Debug)
SetDefault(svc)
return &CoreService{

View file

@ -311,6 +311,35 @@ func TestNewCoreService_InvalidLanguagePreservesSetLanguageError(t *testing.T) {
assert.NotContains(t, msg, "invalid language")
}
func TestNewCoreService_AppliesOptions(t *testing.T) {
prev := Default()
SetDefault(nil)
t.Cleanup(func() {
SetDefault(prev)
})
factory := NewCoreService(ServiceOptions{
Language: "en",
Fallback: "fr",
Formality: FormalityFormal,
Location: "workspace",
Mode: ModeCollect,
Debug: true,
})
_, err := factory(nil)
require.NoError(t, err)
svc := Default()
require.NotNil(t, svc)
assert.Equal(t, "en", svc.Language())
assert.Equal(t, "fr", svc.Fallback())
assert.Equal(t, FormalityFormal, svc.Formality())
assert.Equal(t, "workspace", svc.Location())
assert.Equal(t, ModeCollect, svc.Mode())
assert.True(t, svc.Debug())
}
func TestInit_ReDetectsRegisteredLocales(t *testing.T) {
t.Setenv("LANG", "de_DE.UTF-8")