Documentation ¶
Overview ¶
Package trl is a central store for application environment translations; While specific objects such as QuestionnaireT contain translations for its contents, we need some global store too.
Index ¶
- Variables
- func EnglishMonths() []string
- func HyphenizeText(s string) string
- func MonthsShift(i, shift int) int
- type Map
- type MapSite
- type S
- func (s S) All(args ...string) string
- func (s S) Append(sfx S) S
- func (s S) Append90(sfx S) S
- func (s S) AppendStr(sfx string) S
- func (s S) Bold() S
- func (s S) Empty() bool
- func (s S) Fill(args ...interface{}) S
- func (s S) Left(max int) S
- func (s S) Outline(pref string) S
- func (s S) OutlineHid(pref string) S
- func (s S) Pad(spaces int) S
- func (s S) RemoveSomeHTML() S
- func (s S) Set() bool
- func (s S) Size() float64
- func (s S) String() string
- func (s S) Tr(langCode string) string
- func (s S) TrSilent(langCode string) string
Constants ¶
This section is empty.
Variables ¶
var Countries = map[string]S{}/* 219 elements not displayed */
Countries is contains translations of country names by ISO code
var CountryISOs = []string{}
CountryISOs provides some stable default sorting
var FederalStatesGermany = map[string]S{
"BW": {"de": "Baden-Württemberg"},
"BY": {"de": "Bayern"},
"BE": {"de": "Berlin"},
"BB": {"de": "Brandenburg"},
"HB": {"de": "Bremen"},
"HH": {"de": "Hamburg"},
"HE": {"de": "Hessen"},
"NI": {"de": "Niedersachsen"},
"MV": {"de": "Mecklenburg-Vorpommern"},
"NW": {"de": "Nordrhein-Westfalen"},
"RP": {"de": "Rheinland-Pfalz"},
"SL": {"de": "Saarland"},
"SN": {"de": "Sachsen"},
"ST": {"de": "Sachsen-Anhalt"},
"SH": {"de": "Schleswig-Holstein"},
"TH": {"de": "Thüringen"},
}
FederalStatesGermany for multiple questionnaires
var FederalStatesGermanyISOs = []string{}
FederalStatesGermanyISOs - sorted by ISO code
var FederalStatesGermanyISOs2 = sorterDeSl{}
FederalStatesGermanyISOs2 - sorted by German label
var LangCodes = []string{"de", "en"}
LangCodes for returning multiple translations. When no langCode is available, then the first entry rules. A call to All() returns explicitly all key-values. LangCodes will be initialized in cfg.Load().LangCodes; we prevent circular dependency
Functions ¶
func EnglishMonths ¶
func EnglishMonths() []string
func HyphenizeText ¶
HyphenizeText replaces "mittelfristig" with "mittel|fristig" Hyphenization is done _once_ during creation of the questionare JSON template.
We replace longer keys first, to prevent erratic results for example from
desa|cuer|do
func MonthsShift ¶
MonthsShift could use date.Add - but it would be wasteful
Types ¶
type Map ¶
Map - Translations Type Usage in templates
{{.Trls.imprint.en }} // directly accessing a specific translation; chaining the map keys {{.Trls.imprint.Tr .Sess.LangCode}} // using .Tr(langCode) {{.Trls.imprint.TrSilent .Sess.LangCode}} //
func CoreTranslations ¶
func CoreTranslations() Map
CoreTranslations returns a core of transations, to be extended or overwritten by application config data. To reference app translations in questionnaires, use cfg.Get().Mp[key]
type S ¶
S stores a multi lingual string. Contains one value for each language code.
func (S) All ¶
All returns all translations with their % placeholders filled in by param args; ordered by lang codes separated by '\n\n'
func (S) Fill ¶
Fill fills in the %v placeholders; S is a map - thus always a pointer thus we dont change the receiver, but return a clone
func (S) OutlineHid ¶
OutlineHid prepends pref as comment - invisible
func (S) RemoveSomeHTML ¶
RemoveSomeHTML removes <span *>, </span>, <b>, </b>, .
func (S) String ¶
String is the default "stringer" implementation Similar to Tr() - except third try: take whatever exists