localize

package
v0.1720.0-weblatepr.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package localize provides functionality for English and Welsh language content.

Index

Constants

This section is empty.

Variables

View Source
var LangValues = LangOptions{
	En: En,
	Cy: Cy,
}

Functions

func LowerFirst added in v0.912.0

func LowerFirst(s string) string

Types

type Bundle

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

func NewBundle

func NewBundle(paths ...string) (*Bundle, error)

func (*Bundle) For

func (b *Bundle) For(lang Lang) Localizer

func (*Bundle) LoadMessageFile added in v0.940.0

func (b *Bundle) LoadMessageFile(p string) error

type Lang

type Lang byte
const (
	En Lang = iota + 1 // en
	Cy                 // cy
)

func ParseLang added in v0.884.0

func ParseLang(s string) (Lang, error)

func (Lang) Empty added in v0.884.0

func (i Lang) Empty() bool

func (Lang) IsCy added in v0.884.0

func (i Lang) IsCy() bool

func (Lang) IsEn added in v0.884.0

func (i Lang) IsEn() bool

func (Lang) MarshalText added in v0.912.0

func (i Lang) MarshalText() ([]byte, error)

func (Lang) String

func (i Lang) String() string

func (Lang) URL added in v0.833.0

func (i Lang) URL(path string) string

func (*Lang) UnmarshalText added in v0.1095.0

func (i *Lang) UnmarshalText(text []byte) error

type LangOptions added in v0.884.0

type LangOptions struct {
	En Lang
	Cy Lang
}

type Localizer

type Localizer interface {
	Concat(list []string, joiner string) string
	Count(messageID string, count int) string
	Format(messageID string, data map[string]interface{}) string
	FormatCount(messageID string, count int, data map[string]any) string
	FormatDate(t date.TimeOrDate) string
	FormatDateTime(t time.Time) string
	FormatTime(t time.Time) string
	Lang() Lang
	Possessive(s string) string
	ShowTranslationKeys() bool
	SetShowTranslationKeys(s bool)
	T(messageID string) string
}

type Messages added in v0.940.0

type Messages struct {
	Singles map[string]singleMessage
	Plurals map[string]pluralMessage
}

func (Messages) Find added in v0.940.0

func (m Messages) Find(key string) (singleMessage, bool)

func (Messages) FindPlural added in v0.940.0

func (m Messages) FindPlural(key string, count int) (singleMessage, bool)

Jump to

Keyboard shortcuts

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