Documentation ¶
Index ¶
- Constants
- Variables
- type Conf
- type Translator
- func (l *Translator) MatchLocalizer(lang string) *i18n.Localizer
- func (l *Translator) NewBundle(file embed.FS)
- func (l *Translator) NewBundleFromFile(conf Conf)
- func (l *Translator) NewTranslator()
- func (l *Translator) Trans(ctx context.Context, msgId string) string
- func (l *Translator) TransError(ctx context.Context, err error) error
Constants ¶
View Source
const ( Success = "common.success" Failed = "common.failed" UpdateSuccess = "common.updateSuccess" UpdateFailed = "common.updateFailed" CreateSuccess = "common.createSuccess" CreateFailed = "common.createFailed" DeleteSuccess = "common.deleteSuccess" DeleteFailed = "common.deleteFailed" TargetNotFound = "common.targetNotExist" DatabaseError = "common.databaseError" RedisError = "common.redisError" AlreadyInit = "init.alreadyInit" InitRunning = "init.initializeIsRunning" ConstraintError = "common.constraintError" ValidationError = "common.validationError" NotSingularError = "common.notSingularError" PermissionDeny = "common.permissionDeny" ServiceBusy = "common.serviceBusy" CacheError = "common.cacheError" ApiRequestFailed = "sys.api.apiRequestFailed" )
Variables ¶
View Source
var LocaleFS embed.FS
Functions ¶
This section is empty.
Types ¶
type Conf ¶
type Conf struct {
Dir string `json:",env=I18N_DIR"`
}
Conf is the configuration structure for i18n
type Translator ¶
type Translator struct {
// contains filtered or unexported fields
}
Translator is a struct storing translating data. 翻译器是一个存储翻译数据的结构。
func NewTranslator ¶
func NewTranslator(file embed.FS) *Translator
NewTranslator returns a translator by FS.
func NewTranslatorFromFile ¶
func NewTranslatorFromFile(conf Conf) *Translator
NewTranslatorFromFile returns a translator by FS.
func (*Translator) MatchLocalizer ¶
func (l *Translator) MatchLocalizer(lang string) *i18n.Localizer
MatchLocalizer used to matcher the localizer in map 用于匹配地图中定位器的 MatchLocalizer
func (*Translator) NewBundle ¶
func (l *Translator) NewBundle(file embed.FS)
NewBundle returns a bundle from FS. NewBundle 从 FS 返回一个捆绑包。
func (*Translator) NewBundleFromFile ¶
func (l *Translator) NewBundleFromFile(conf Conf)
NewBundleFromFile returns a bundle from a directory which contains i18n files.
func (*Translator) NewTranslator ¶
func (l *Translator) NewTranslator()
NewTranslator sets localize for translator.
func (*Translator) Trans ¶
func (l *Translator) Trans(ctx context.Context, msgId string) string
Trans used to translate any i18n string.
func (*Translator) TransError ¶
func (l *Translator) TransError(ctx context.Context, err error) error
TransError translates the error message TransError 翻译错误信息
Click to show internal directories.
Click to hide internal directories.