i18n

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: Apache-2.0 Imports: 13 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Bundle     *goi18n.Bundle
	Localizers map[string]*goi18n.Localizer
)

Functions

func FormatMultiple

func FormatMultiple(value any) string

FormatMultiple rounds a baseline/candidate ratio for display and groups thousands. Persisted arguments keep the unrounded ratio.

func FormatPercent

func FormatPercent(value any) string

FormatPercent rounds display text only. Values that would round across 0% or 100% keep enough decimals to avoid claiming a complete elimination or no change. Persisted message arguments retain their precision.

func ImprovementMultiple

func ImprovementMultiple(baseline, candidate float64) (float64, bool)

ImprovementMultiple is baseline/candidate when that ratio is a finite improvement that still displays as more than 1x. Cost reduction percent cannot exceed 100; this ratio is the separate "how many times" figure.

func LoadTranslateFile

func LoadTranslateFile(fp string) error

func LoadTranslateFileFS

func LoadTranslateFileFS(fsys fs.FS, fp string) error

func Localize

func Localize(lang string, msg *goi18n.Message, args map[string]any) string

func LocalizeWithCatalog

func LocalizeWithCatalog(catalog *Catalog, lang string, msg *goi18n.Message, args map[string]any) string

Types

type Catalog

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

func DefaultCatalog

func DefaultCatalog() *Catalog

func NewCatalog

func NewCatalog() *Catalog

func (*Catalog) LoadTranslateFile

func (c *Catalog) LoadTranslateFile(fp string) error

func (*Catalog) LoadTranslateFileFS

func (c *Catalog) LoadTranslateFileFS(fsys fs.FS, fp string) error

func (*Catalog) LoadTranslateFiles

func (c *Catalog) LoadTranslateFiles(files ...string) error

func (*Catalog) LoadTranslateFilesFS

func (c *Catalog) LoadTranslateFilesFS(fsys fs.FS, files ...string) error

func (*Catalog) Localize

func (c *Catalog) Localize(lang string, msg *goi18n.Message, args map[string]any) string

Jump to

Keyboard shortcuts

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