github.com/wfusion/gofusion@v1.1.14/i18n/types.go (about) 1 package i18n 2 3 import ( 4 "golang.org/x/text/language" 5 6 "github.com/wfusion/gofusion/common/utils" 7 ) 8 9 type Localizable[T comparable] interface { 10 AddMessages(code T, trans map[language.Tag]*Message, opts ...utils.OptionExtender) Localizable[T] 11 Localize(code T, opts ...utils.OptionExtender) (message string) 12 } 13 14 // Conf i18n configure 15 type Conf struct { 16 DefaultLang string `yaml:"default_lang" json:"default_lang" toml:"default_lang" default:"zh"` 17 } 18 19 // Message is a string that can be localized. 20 type Message struct { 21 // ID uniquely identifies the message. 22 ID string 23 24 // Hash uniquely identifies the content of the message 25 // that this message was translated from. 26 Hash string 27 28 // Description describes the message to give additional 29 // context to translators that may be relevant for translation. 30 Description string 31 32 // LeftDelim is the left Go template delimiter. 33 LeftDelim string 34 35 // RightDelim is the right Go template delimiter.`` 36 RightDelim string 37 38 // Zero is the content of the message for the CLDR plural form "zero". 39 Zero string 40 41 // One is the content of the message for the CLDR plural form "one". 42 One string 43 44 // Two is the content of the message for the CLDR plural form "two". 45 Two string 46 47 // Few is the content of the message for the CLDR plural form "few". 48 Few string 49 50 // Many is the content of the message for the CLDR plural form "many". 51 Many string 52 53 // Other is the content of the message for the CLDR plural form "other". 54 Other string 55 }