translator

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: AGPL-3.0 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