i18n

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 3 Imported by: 0 modules, 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

Overview

Package i18n provides locale-aware translation lookups. It has no dependencies on PDF rendering, layout, or domain models.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type I18n

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

I18n handles internationalization and translation lookups.

func New

func New(locale string) (*I18n, error)

New creates a self-contained I18n instance with generic number separators.

func NewFromSource

func NewFromSource(locale string, source map[string]any) (*I18n, error)

NewFromSource creates a new I18n instance from a parsed JSON source object. The source should match the same i18n JSON structure used by i18n.json.

func (*I18n) FloatSeparator

func (i *I18n) FloatSeparator() string

FloatSeparator returns the decimal separator for the current locale.

func (*I18n) KiloSeparator

func (i *I18n) KiloSeparator() string

KiloSeparator returns the thousands separator for the current locale.

func (*I18n) Locale

func (i *I18n) Locale() string

Locale returns the current locale.

func (*I18n) T

func (i *I18n) T(key string) string

T translates a key to the current locale. If the key is not found, returns the key itself.

func (*I18n) TWithVars

func (i *I18n) TWithVars(key string, vars map[string]string) string

TWithVars translates a key and replaces {{varName}} placeholders.

func (*I18n) TemplateData

func (i *I18n) TemplateData(vars map[string]string) map[string]any

TemplateData returns all translations as a nested template object, applying placeholder vars to every value.

Jump to

Keyboard shortcuts

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