-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathlocale_test.go
More file actions
30 lines (23 loc) · 802 Bytes
/
Copy pathlocale_test.go
File metadata and controls
30 lines (23 loc) · 802 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Copyright 2020 ChaiShushan <chaishushan{AT}gmail.com>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package gettext
import (
"testing"
)
func TestLocale(t *testing.T) {
l := newLocale("hello", "./examples/locale", nil).SetLanguage("zh_CN")
testLocal_zh_CN(t, l)
l = newLocale("hello", "./examples/locale.zip", nil).SetLanguage("zh_CN")
testLocal_zh_CN(t, l)
}
func testLocal_zh_CN(t *testing.T, l Gettexter) {
lang := l.GetLanguage()
tAssert(t, lang == "zh_CN", lang)
expect := "你好, 世界!"
got := l.Gettext("Hello, world!")
tAssert(t, got == expect, got, expect)
expect = "你好, 世界!(ctx:main.main)"
got = l.PGettext("main.main", "Hello, world!")
tAssert(t, got == expect, got, expect)
}