lang

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2024 License: Apache-2.0 Imports: 12 Imported by: 8

README

godoc Go Report Card

lang - text language utilities

A collection of common functions and catalog constructs for text language processing.

Note that there is no documentation and these utilities are intended for the needs of the go-enjin/be and enjenv projects at this time.

Installation

> go get github.com/go-corelibs/lang@latest

Go-CoreLibs

Go-CoreLibs is a repository of shared code between the Go-Curses and Go-Enjin projects.

License

Copyright 2024 The Go-CoreLibs Authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use file except in compliance with the License.
You may obtain a copy of the license at

 http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Documentation

Overview

Package lang provides text language utilities

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CoalesceTranslatorComment

func CoalesceTranslatorComment(input string) (coalesced string)

func ParsePluralCaseKey

func ParsePluralCaseKey(key string) (real string)

func ParseTag

func ParseTag(input interface{}) (tag language.Tag, err error)

func ParseTranslatorComment

func ParseTranslatorComment(input string) (comments, sources []string)

func PruneCommandTranslatorComments added in v0.2.0

func PruneCommandTranslatorComments(raw string) (clean string)

func PruneInlineTranslatorComments added in v0.2.0

func PruneInlineTranslatorComments(raw string) (clean string)

func PruneTranslatorComments

func PruneTranslatorComments(input string) (clean string)

func SortLanguageTags

func SortLanguageTags(tags []language.Tag) (sorted []language.Tag)

func SortedLanguageTagKeys

func SortedLanguageTagKeys[V interface{}](m map[language.Tag]V) (sorted []language.Tag)

func TagInTagSlices

func TagInTagSlices(needle language.Tag, haystacks ...[]language.Tag) (found bool)

func TagInTags

func TagInTags(needle language.Tag, haystack ...language.Tag) (found bool)

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 GoText

type GoText struct {
	Language string     `json:"language"`
	Messages []*Message `json:"messages"`
}

func ParseGoText

func ParseGoText(data []byte) (gt *GoText, tag language.Tag, err error)

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 MakeMessageFromKey(key, comment string, argv ...string) (m *Message)

func ParseTemplateMessages

func ParseTemplateMessages(input string) (msgs []*Message, err error)

func (*Message) Copy

func (m *Message) Copy() (copied *Message)

func (*Message) MarshalJSON

func (m *Message) MarshalJSON() (data []byte, err error)

func (*Message) UnmarshalJSON

func (m *Message) UnmarshalJSON(data []byte) (err error)

type Placeholder

type Placeholder struct {
	ID             string `json:"id"`
	String         string `json:"string"`
	Type           string `json:"type"`
	UnderlyingType string `json:"underlyingType"`
	ArgNum         int    `json:"argNum"`
	Expr           string `json:"expr"`
}

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 Tags

type Tags []language.Tag

func (Tags) Has

func (list Tags) Has(tag language.Tag) (present bool)

func (Tags) Strings

func (list Tags) Strings() (locales []string)

func (Tags) StringsWithDefault

func (list Tags) StringsWithDefault(tag language.Tag) (locales []string)

type Translation

type Translation struct {
	String string  `json:"string,omitempty"`
	Select *Select `json:"select,omitempty"`
}

Jump to

Keyboard shortcuts

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