strMapping

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2023 License: GPL-3.0 Imports: 12 Imported by: 18

Documentation

Overview

Package strMapping implements a mapping between keys and longer strings. Mappings are stored in multiline strings (may be stored themselves in files), each line defining a mapping: <key> tabulation <mapped string>.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetLStr

func SetLStr(base string, lS LinkStrings)

SetLStr fixes the LinkStrings function 'ls' for the base 'base'. Optional. The default LinkStrings function for the base 'base' associates the language 'lang' to the string contained in the file "<resource directory>/base/lang/strings.txt". For <resource directory>, see the package "util/resources".

Types

type Lang

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

func NewLanguage

func NewLanguage(lang string) *Lang

func NewStdLanguage

func NewStdLanguage() *Lang

Language returns the current standard language

func (*Lang) Language

func (l *Lang) Language() string

Language returns the current language in 'l'

func (*Lang) Map

func (l *Lang) Map(key string, p ...string) string

Map translates a key string 'key' into a mapped string. Strings of the form "#base:message" are translated if there is a corresponding 'base' resource string (or file) for this base. Otherwise, the "#base:" prefix is stripped away. As an example, "#system:Cancel" may be translated to "Cancel" in the USA, and to "Abbrechen" in Germany; or to "Cancel" if the resource file or the appropriate entry is missing. Additional input parameters can be spliced into the resulting string. These parameters 'p' are inserted where "^0", "^1", "^2", etc... occur in the resulting string (^0 for the first parameter, ^1 for the second, etc...). The parameters are not mapped, but merely substituted. Map allows to remove country- and language-specific strings from a program source text, while at the same time providing a default string in the program source text such that the program always works, even if string resources are missing.

type LinkStrings

type LinkStrings func(lang string) (io.ReadCloser, bool)

LinkStrings functions return an io.ReadCloser able to read a string containing mappings for the language 'lang'.

Jump to

Keyboard shortcuts

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