i18n

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingPluralForm = errors.New(`plural message has no "other" form`)
)

Functions

func ErrorText

func ErrorText(err error) string

ErrorText returns a localized error message

func Register added in v0.2.1

func Register(values Translations)

Register adds startup module translations

func Text

func Text(key Key, vars ...Vars) string

Text returns a localized message with optional named interpolation

Types

type Error

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

Error identifies a localizable error and its interpolation variables

func NewError

func NewError[S ~string](key S) *Error

NewError returns an error backed by a localized message

func (*Error) Error

func (e *Error) Error() string

Error returns the translated message for the current locale

func (*Error) WithVars

func (e *Error) WithVars(vars Vars) *Error

WithVars returns a copy with interpolation variables attached

type Key

type Key string

Key identifies a localized message

const (
	PromptCommand Key = "prompt.command"
	ToastTitle    Key = "toast.title"

	ErrorMessage        Key = "error.message"
	ErrorNoDocument     Key = "error.noDocument"
	ErrorNoSuchCommand  Key = "error.noSuchCommand"
	ErrorInvalidKey     Key = "error.invalidKey"
	ErrorInvalidBinding Key = "error.invalidBinding"
	ErrorBindingExists  Key = "error.bindingExists"

	ErrorAleCommandArguments    Key = "error.aleCommandArguments"
	ErrorAleCommandUnavailable  Key = "error.aleCommandUnavailable"
	ErrorAleContext             Key = "error.aleContext"
	ErrorAleBindingModeType     Key = "error.aleBindingModeType"
	ErrorAleBindingUnknownMode  Key = "error.aleBindingUnknownMode"
	ErrorAleBindingPairs        Key = "error.aleBindingPairs"
	ErrorAleBindingAction       Key = "error.aleBindingAction"
	ErrorAleBindingOptionNames  Key = "error.aleBindingOptionNames"
	ErrorAleBindingDuplicate    Key = "error.aleBindingDuplicate"
	ErrorAleBindingKeyTypes     Key = "error.aleBindingKeyTypes"
	ErrorAleBindingDocType      Key = "error.aleBindingDocType"
	ErrorAleBindingWhenType     Key = "error.aleBindingWhenType"
	ErrorAleBindingUnknown      Key = "error.aleBindingUnknown"
	ErrorAleBindingModesMissing Key = "error.aleBindingModesMissing"
	ErrorAleBindingModesEmpty   Key = "error.aleBindingModesEmpty"
	ErrorAleBindingKeysMissing  Key = "error.aleBindingKeysMissing"
	ErrorAleBindingKeysEmpty    Key = "error.aleBindingKeysEmpty"

	ErrorWorkspaceUntrustedHint Key = "error.workspaceUntrustedHint"

	StatusClipboardCopied Key = "status.clipboardCopied"
	StatusCounted         Key = "status.counted"

	StatusPickerTypeToSearch Key = "status.pickerTypeToSearch"
	StatusPickerSearching    Key = "status.pickerSearching"
	StatusPickerNoResults    Key = "status.pickerNoResults"
	StatusImageLoading       Key = "status.imageLoading"
	StatusImageUnsupported   Key = "status.imageUnsupported"
	StatusTerminalStarting   Key = "status.terminalStarting"
	StatusPaneMaximized      Key = "status.paneMaximized"
	StatusMacroRecording     Key = "status.macroRecording"

	StatusFileDeleted          Key = "status.fileDeleted"
	StatusFileChanged          Key = "status.fileChanged"
	StatusReloadFailed         Key = "status.reloadFailed"
	StatusFileReloaded         Key = "status.fileReloaded"
	StatusFileWatchUnavailable Key = "status.fileWatchUnavailable"
)

type Translations added in v0.2.1

type Translations map[Key]string

Translations contains messages resolved for the current locale

func LoadTranslations added in v0.2.1

func LoadTranslations(files fs.FS) Translations

LoadTranslations loads and resolves every locale file in files. Each embedded set holds exactly one module's translations, so the whole tree is taken rather than a caller-supplied glob

type Vars

type Vars map[string]any

Vars supplies named values for message interpolation

Jump to

Keyboard shortcuts

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