Help us shape the future of Go! Take the 2026 Go Developer Survey

translator

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 19, 2025 License: Apache-2.0, MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	FullMatchRules []ConfigRuleFullMatch `mapstructure:"FullMatchRules"`
}

type ConfigRuleFullMatch

type ConfigRuleFullMatch struct {
	ContextName string `mapstructure:"ContextName"`
	Old         string `mapstructure:"Old"`
	New         string `mapstructure:"New"`
}

type Translator

type Translator interface {
	Translate(contextName string, data string) string
}

type TranslatorFullMatchRule

type TranslatorFullMatchRule struct {
	// If null match any context
	ContextName *string
	// If null match any data
	FullMatchString string
	NewString       string
}

func NewTranslatorFullMatchRule

func NewTranslatorFullMatchRule(
	contextName *string, fullMatchString string, newString string,
) *TranslatorFullMatchRule

func (*TranslatorFullMatchRule) Match

func (t *TranslatorFullMatchRule) Match(contextName string, data string) bool

func (*TranslatorFullMatchRule) Translate

func (t *TranslatorFullMatchRule) Translate(contextName string, data string) string

type TranslatorImpl

type TranslatorImpl struct {
	FullMatchRules []TranslatorFullMatchRule
	// contains filtered or unexported fields
}

func NewTranslatorImpl

func NewTranslatorImpl(logger *log.Logger) *TranslatorImpl

func (*TranslatorImpl) AddConfigRules

func (t *TranslatorImpl) AddConfigRules(cfg Config)

func (*TranslatorImpl) AddRule

func (t *TranslatorImpl) AddRule(rule TranslatorFullMatchRule)

func (*TranslatorImpl) Translate

func (t *TranslatorImpl) Translate(contextName string, data string) string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL