...

Source file src/github.com/chai2010/gettext-go/locale_test.go

Documentation: github.com/chai2010/gettext-go

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

View as plain text