package i18n_test import ( "context" "git.noahlan.cn/noahlan/ntool-biz/core/i18n" "git.noahlan.cn/noahlan/ntool/ntest/assert" "testing" ) func TestTrans(t *testing.T) { ctx := context.Background() result1 := i18n.Trans(ctx, "success") result2 := i18n.Trans(context.WithValue(ctx, i18n.KeyLang, "en"), "success") assert.Eq(t, "成功", result1) assert.Eq(t, "Successfully", result2) } func TestTransWithParam(t *testing.T) { ctx := context.Background() result1 := i18n.TransWithParam(ctx, "hello", "王二", "麻子") assert.Eq(t, "王二麻子", result1) }