Documentation ¶
Overview ¶
Package lang provides text language utilities
Index ¶
- Variables
- func CoalesceTranslatorComment(input string) (coalesced string)
- func ParsePluralCaseKey(key string) (real string)
- func ParseTag(input interface{}) (tag language.Tag, err error)
- func ParseTranslatorComment(input string) (comments, sources []string)
- func Prune(input, characters string) string
- func PruneTranslatorComments(input string) (clean string)deprecated
- func SortLanguageTags(tags []language.Tag) (sorted []language.Tag)
- func SortedLanguageTagKeys[V interface{}](m map[language.Tag]V) (sorted []language.Tag)
- func TagInTagSlices(needle language.Tag, haystacks ...[]language.Tag) (found bool)
- func TagInTags(needle language.Tag, haystack ...language.Tag) (found bool)
- type BaseMessage
- type GoText
- type Message
- type Messages
- type Placeholder
- type Placeholders
- type Select
- type SelectCase
- type SelectMessage
- type StringMessage
- type Tags
- type Translation
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // TranslationCommandName is the name of the text and html template // FuncMap entry responsible for rendering translated text. The named // function must support a [fmt.Sprintf]-like call signature // // By default, the TranslationCommandName is set to the Go-Enjin standard // translation function (which is just a single underscore) TranslationCommandName = "_" // TrimLayoutsFromFilename determines whether ParseTemplateTranslations // will remove the `.../layouts/` parent paths from the filename TrimLayoutsFromFilename = true )
Functions ¶
func ParsePluralCaseKey ¶
func ParseTranslatorComment ¶
func Prune ¶ added in v0.3.0
Prune removes all characters from input
TODO: move Prune to github.com/go-corelibs/strings
func PruneTranslatorComments
deprecated
Deprecated: PruneTranslatorComments is now a simple wrapper around the generically useful and optimized: github.com/go-corelibs/tmplstr.RemoveTemplateComments
func SortedLanguageTagKeys ¶
func TagInTagSlices ¶
Types ¶
type BaseMessage ¶
type BaseMessage struct { ID string `json:"id"` Key string `json:"key"` Message string `json:"message"` Translation interface{} `json:"translation"` TranslatorComment string `json:"translatorComment,omitempty"` Placeholders Placeholders `json:"placeholders,omitempty"` Fuzzy bool `json:"fuzzy,omitempty"` }
type Message ¶
type Message struct { ID string `json:"id"` Key string `json:"key"` Message string `json:"message"` Translation *Translation `json:"translation"` TranslatorComment string `json:"translatorComment,omitempty"` Placeholders Placeholders `json:"placeholders,omitempty"` Fuzzy bool `json:"fuzzy,omitempty"` }
func MakeMessageFromKey ¶
func ParseTemplateTranslations ¶ added in v0.3.0
ParseTemplateTranslations uses github.com/go-corelibs/tmplstr ParseTemplate and searches for any actions calling TranslationCommandName, parsing the message ID, arguments and comments into a Message structure
func (*Message) MarshalJSON ¶
func (*Message) UnmarshalJSON ¶
type Placeholder ¶
type Placeholders ¶
type Placeholders []*Placeholder
func ParseMessagePlaceholders ¶
func ParseMessagePlaceholders(key string, argv ...string) (replaced, labelled string, placeholders Placeholders)
func (Placeholders) Copy ¶
func (p Placeholders) Copy() (copied Placeholders)
func (Placeholders) Numeric ¶
func (p Placeholders) Numeric() (found Placeholders)
type Select ¶
type Select struct { Arg string `json:"arg"` Feature string `json:"feature"` Cases map[string]SelectCase `json:"cases"` }
type SelectCase ¶
type SelectCase struct {
Msg string `json:"msg"`
}
type SelectMessage ¶
type SelectMessage struct { ID string `json:"id"` Key string `json:"key"` Message string `json:"message"` Translation *Translation `json:"translation"` TranslatorComment string `json:"translatorComment,omitempty"` Placeholders Placeholders `json:"placeholders,omitempty"` Fuzzy bool `json:"fuzzy,omitempty"` }
func (*SelectMessage) Make ¶
func (s *SelectMessage) Make() (m Message)
type StringMessage ¶
type StringMessage struct { ID string `json:"id"` Key string `json:"key"` Message string `json:"message"` Translation string `json:"translation"` TranslatorComment string `json:"translatorComment,omitempty"` Placeholders Placeholders `json:"placeholders,omitempty"` Fuzzy bool `json:"fuzzy,omitempty"` }
func (*StringMessage) Make ¶
func (s *StringMessage) Make() (m Message)
type Translation ¶
Click to show internal directories.
Click to hide internal directories.