lang

package
v0.10.3 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2023 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Dicts = map[string]*Dict{}

Dicts the dictionaries loaded

View Source
var Widgets = map[string]string{
	"models": "model",
	"flows":  "flow",
	"apis":   "api",
}

Widgets build-in widgets path mapping

Functions

func Load added in v0.10.2

func Load(root string) error

Load the language dictionaries from the path

func RegisterWidget added in v0.10.2

func RegisterWidget(path, name string)

RegisterWidget Register the path of widget

func Replace added in v0.10.2

func Replace(value *string) bool

Replace replace the value in the global dictionary if was replaced return true else return false

Types

type Dict added in v0.10.2

type Dict struct {
	Name    string
	Global  Words
	Widgets map[string]Words
}

Dict the language dictionary

var Default *Dict = &Dict{Global: Words{}, Widgets: map[string]Words{}}

Default the default language

func Open added in v0.10.2

func Open(langRoot string) (*Dict, error)

Open the dictionary from the language dictionary root

func Pick added in v0.10.2

func Pick(name string) *Dict

Pick get the dictionary by the ISO 639-1 standard language code

func (*Dict) Apply added in v0.10.2

func (dict *Dict) Apply(lang Lang)

Apply Replace the words in the dictionary if was replaced return true else return false

func (*Dict) AsDefault added in v0.10.2

func (dict *Dict) AsDefault() *Dict

AsDefault set current dict as default

func (*Dict) Merge added in v0.10.2

func (dict *Dict) Merge(new *Dict)

Merge the new dict

func (*Dict) Replace added in v0.10.2

func (dict *Dict) Replace(names []string, value *string) bool

Replace replace the value in the dictionary if was replaced return true else return false

func (*Dict) ReplaceAll added in v0.10.2

func (dict *Dict) ReplaceAll(widgets []string, ptr interface{}) error

ReplaceAll replace the value in dictionary

func (*Dict) ReplaceClone added in v0.10.2

func (dict *Dict) ReplaceClone(widgets []string, input interface{}) (interface{}, error)

ReplaceClone replace the value in dictionary

func (*Dict) ReplaceMatch added in v0.10.2

func (dict *Dict) ReplaceMatch(names []string, value *string) bool

ReplaceMatch replace the value in the dictionary

type Lang added in v0.10.2

type Lang interface {
	Lang(trans func(widgetName string, inst string, value *string) bool)
}

Lang the language interface

type Words added in v0.10.2

type Words map[string]string

Words the language words

func OpenYaml added in v0.10.2

func OpenYaml(file string) (Words, error)

OpenYaml dict file

Jump to

Keyboard shortcuts

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