langkit

package
v0.0.0-...-9e9b37c Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ForContext func(ctx context.Context) Translations

Functions

func Get

func Get(ctx context.Context, original string, formatArgs ...interface{}) string

func GetPlural

func GetPlural(ctx context.Context, original string, originalPlural string, count int, formatArgs ...interface{}) string

func TranslateMissingWithOpenAI

func TranslateMissingWithOpenAI(apiKey string, potFile string, targetPoFilesGlob string)

Types

type Matcher

type Matcher func(filename string, input []byte, printStatus bool) ([]TextMatch, error)

func SimpleGetMatcher

func SimpleGetMatcher(prefix string) Matcher

func SimpleGetPluralMatcher

func SimpleGetPluralMatcher(prefix string) Matcher

type Module

type Module struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewModule

func NewModule(path string, lazyLoad bool) (*Module, error)

func (*Module) FindTranslations

func (d *Module) FindTranslations(locale string) Translations

type NoTranslations

type NoTranslations struct {
	// contains filtered or unexported fields
}

func (*NoTranslations) Get

func (t *NoTranslations) Get(original string, formatArgs ...interface{}) string

func (*NoTranslations) GetPlural

func (t *NoTranslations) GetPlural(original string, originalPlural string, count int, formatArgs ...interface{}) string

type Pod

type Pod map[string]string

Pod contains a string translated into multiple languages. It's ment to be serialized and stored on entities in databases, such as on "product description" or "title" columns.

func CreatePod

func CreatePod(def string) Pod

func ParsePod

func ParsePod(msg json.RawMessage) Pod

func (Pod) Default

func (t Pod) Default() string

func (Pod) Get

func (t Pod) Get(locale string) string

func (Pod) JSON

func (t Pod) JSON() json.RawMessage

type TextExtractor

type TextExtractor struct {
	// contains filtered or unexported fields
}

func NewTextExtractor

func NewTextExtractor(basepath string) *TextExtractor

func (*TextExtractor) Exclude

func (e *TextExtractor) Exclude(pathGlob string)

func (*TextExtractor) ExtractTo

func (e *TextExtractor) ExtractTo(outputFile string, printStatus bool) error

func (*TextExtractor) ExtractToP

func (e *TextExtractor) ExtractToP(outputFile string, printStatus bool)

func (*TextExtractor) Include

func (e *TextExtractor) Include(pathGlob string)

func (*TextExtractor) Match

func (e *TextExtractor) Match(matcher Matcher)

type TextMatch

type TextMatch struct {
	Source         string
	Comment        string
	Original       string
	OriginalPlural string
}

type Translations

type Translations interface {
	Get(original string, formatArgs ...interface{}) string
	GetPlural(original string, originalPlural string, count int, formatArgs ...interface{}) string
}

func ReadPoFile

func ReadPoFile(filepath string, lazyLoad bool) (Translations, error)

Jump to

Keyboard shortcuts

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