localize

package
v0.1708.0-MLPAB2711sen... Latest Latest
Warning

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

Go to latest
Published: Feb 19, 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 DefaultLocalizer

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

func (*DefaultLocalizer) Concat

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

func (*DefaultLocalizer) Count

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

func (*DefaultLocalizer) Format

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

func (*DefaultLocalizer) FormatCount

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

func (*DefaultLocalizer) FormatDate

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

func (*DefaultLocalizer) FormatDateTime

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

func (*DefaultLocalizer) FormatTime

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

func (*DefaultLocalizer) Lang

func (l *DefaultLocalizer) Lang() Lang

func (*DefaultLocalizer) Possessive

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

func (*DefaultLocalizer) SetShowTranslationKeys

func (l *DefaultLocalizer) SetShowTranslationKeys(s bool)

func (*DefaultLocalizer) ShowTranslationKeys

func (l *DefaultLocalizer) ShowTranslationKeys() bool

func (*DefaultLocalizer) T

func (l *DefaultLocalizer) T(messageID string) string

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