You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
576 B
Go
27 lines
576 B
Go
1 year ago
|
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)
|
||
|
}
|