[agent/codex:gpt-5.4-mini] Read ~/spec/code/core/go/i18n/RFC.md fully. Find ONE feature... #126

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

View file

@ -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 {

View file

@ -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) {