localize

package
v0.1549.0-MLPAB2454bac... Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 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 struct {
	Lang Lang
	// contains filtered or unexported fields
}

func (*Localizer) Concat

func (l *Localizer) Concat(list []string, joiner string) string

func (*Localizer) Count

func (l *Localizer) Count(messageID string, count int) string

func (*Localizer) Format

func (l *Localizer) Format(messageID string, data map[string]interface{}) string

func (*Localizer) FormatCount

func (l *Localizer) FormatCount(messageID string, count int, data map[string]any) string

func (*Localizer) FormatDate added in v0.842.0

func (l *Localizer) FormatDate(t date.TimeOrDate) string

func (*Localizer) FormatDateTime added in v0.842.0

func (l *Localizer) FormatDateTime(t time.Time) string

func (*Localizer) FormatTime added in v0.1054.0

func (l *Localizer) FormatTime(t time.Time) string

func (*Localizer) Possessive

func (l *Localizer) Possessive(s string) string

func (*Localizer) SetShowTranslationKeys

func (l *Localizer) SetShowTranslationKeys(s bool)

func (*Localizer) ShowTranslationKeys

func (l *Localizer) ShowTranslationKeys() bool

func (*Localizer) T

func (l *Localizer) 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