[agent/codex:gpt-5.4-mini] Read ~/spec/code/core/go/i18n/RFC.md fully. Find ONE feature... #126
2 changed files with 21 additions and 0 deletions
8
i18n.go
8
i18n.go
|
|
@ -16,6 +16,14 @@ func T(messageID string, args ...any) string {
|
|||
return messageID
|
||||
}
|
||||
|
||||
// Translate translates a message using the default service and returns a Core result.
|
||||
func Translate(messageID string, args ...any) core.Result {
|
||||
if svc := Default(); svc != nil {
|
||||
return svc.Translate(messageID, args...)
|
||||
}
|
||||
return core.Result{Value: messageID, OK: true}
|
||||
}
|
||||
|
||||
// Raw translates without i18n.* namespace magic.
|
||||
func Raw(messageID string, args ...any) string {
|
||||
if svc := Default(); svc != nil {
|
||||
|
|
|
|||
13
i18n_test.go
13
i18n_test.go
|
|
@ -39,6 +39,19 @@ func TestT_Good_MissingKey(t *testing.T) {
|
|||
assert.Equal(t, "nonexistent.key.test", got)
|
||||
}
|
||||
|
||||
// --- Package-level Translate() ---
|
||||
|
||||
func TestTranslate_Good(t *testing.T) {
|
||||
svc, err := New()
|
||||
require.NoError(t, err)
|
||||
_ = Init()
|
||||
SetDefault(svc)
|
||||
|
||||
result := Translate("prompt.yes")
|
||||
require.True(t, result.OK)
|
||||
assert.Equal(t, "y", result.Value)
|
||||
}
|
||||
|
||||
// --- Package-level Raw() ---
|
||||
|
||||
func TestRaw_Good(t *testing.T) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue