languages

package
v2.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2026 License: MIT Imports: 18 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 languages is the host of the languages icebath speaks to people in: the catalogs bundled with it, each profile's own and the language packs of its extensions, and which language a profile, a window, a request and a session speak

Index

Constants

View Source
const Domains = "domains.yaml"

File of the bundled catalogs that names the domain file of each folder of the tree, and the folders whose texts are all messages

View Source
const Folder = "locales"

Folder of a profile, and of a catalog folder, that holds a user's own catalogs: a folder of YAML files or one YAML file per language

Variables

This section is empty.

Functions

func Carried

func Carried(id string) *lang.Language

The language of the id as icebath carries it, from the bundled catalogs alone: what a window speaks before its server tells it more

func Carries

func Carries(id string) bool

Whether icebath carries catalogs of the language, English always

func Computer

func Computer() string

The language this computer is set to for its user, empty when nothing names one

func English

func English(key string) (string, bool)

The English format a key stands for, the other form of a plural, and whether it is a plural, as lang.Parts reads a key: its English, the one and the other form of a plural apart by lang.PluralMark, or the English and its context in the marks of a context. A structural name stands for no English

func Replaces

func Replaces(id, key string) bool

Whether words a pack brings for the text of the key in the language would replace icebath's own: the language is one icebath speaks and the text one it carries words for. A pack leaves those out, so none changes what icebath itself says, its approval prompts among it, in a language icebath speaks, nor in one that falls back to such a language and that a computer could pick on its own

func Speaks

func Speaks(id string) bool

Whether the language, or one it falls back to, is one icebath carries, English among them: one icebath speaks by its own words

func Told

func Told() string

Told returns the language this computer is set to as far as it is told without running a program: the locale of the environment, otherwise what the system answers directly. It is empty where only a program could tell, which Computer runs.

func Unformed

func Unformed(id string, catalog lang.Catalog) map[string][]plural.Form

Plural entries of a catalog of the language whose forms are not those its CLDR rules use for whole numbers and no other, the rule the bundled catalogs are held to: the forms each has, by key. None when every one keeps it. lang.Needed says the forms the language needs

Types

type Languages

type Languages struct {
	Registry
	// contains filtered or unexported fields
}

func New

func New(cfg *config.Config) *Languages

func (*Languages) Accepting

func (l *Languages) Accepting(cfg *config.Config, accept string) *lang.Language

The language a request of the HTTP API speaks, by the languages the program accepts in the order it prefers them, after the profile's own choice

func (*Languages) Asked

func (l *Languages) Asked(profile, named string) *lang.Language

The language a request of a window speaks: the one the window names, which it resolved itself, otherwise what the profile the window works on speaks. The profile in use when the window names none

func (*Languages) Chosen

func (l *Languages) Chosen(cfg *config.Config) string

Chosen returns the profile's language, or "" when none is set or the language is gone.

func (*Languages) Entries

func (l *Languages) Entries(cfg *config.Config, id string) lang.Catalog

Every entry of the language of the profile from all its layers, the first layer's words winning, which a window speaks it with

func (*Languages) Export

func (l *Languages) Export(cfg *config.Config, id string) (string, int, error)

Writes the texts the language of the profile lacks into the profile's own folder of catalogs, each with no words, for a translator to fill in. The file and how many texts it holds

func (*Languages) Folders

func (l *Languages) Folders(cfg *config.Config) []string

Folders of the profile's catalogs a user writes: its own, and the catalog folder its settings name

func (*Languages) For

func (l *Languages) For(cfg *config.Config, told ...string) *lang.Language

The language the profile of the settings speaks to a person: the one it chose, otherwise the first of those told of the user that it has (what a chat app says of them, what a program accepts), otherwise this computer's, otherwise English

func (*Languages) Has

func (l *Languages) Has(cfg *config.Config, id string) bool

Whether the profile has the language

func (*Languages) Ids

func (l *Languages) Ids(cfg *config.Config) []string

Ids of the languages of the profile of the settings: English, the bundled ones, those its own catalogs and its packs bring, sorted with English first

func (*Languages) Kept

func (l *Languages) Kept(dir string, where lang.Text) Words

Words of a folder of catalogs as the host keeps them, read again once its files changed and at most every few seconds. The catalogs are the host's, which a caller copies before it changes them

func (*Languages) Language

func (l *Languages) Language(cfg *config.Config, id string) *lang.Language

The language of the id as the profile speaks it: the words of its packs, its own catalogs and the bundled ones, of the id and of each tag it falls back to, then the English of the sites

func (*Languages) Problems

func (l *Languages) Problems(cfg *config.Config) []Problem

What is wrong in the catalogs of the profile: its own, those of the catalog folder, the packs, and the bundled ones: what does not read, words whose placeholders differ from their English, and texts that name nothing icebath says

func (*Languages) Reference

func (l *Languages) Reference(cfg *config.Config) map[string]bool

Every text icebath says that the profile knows of: the keys of every bundled language, and the copy of the settings of the profile by its English

func (*Languages) Register

func (l *Languages) Register(registrant Registrant)

Adds a registrant. A registry nested in the host reaches it through Host

func (*Languages) Resolve

func (l *Languages) Resolve(cfg *config.Config, value string) (string, bool)

The language of the profile a value stands for: an id, a name, a tag or a locale, false for none it has

func (*Languages) Said

func (l *Languages) Said(cfg *config.Config, id string, reference map[string]bool) int

How many of the texts of the reference the language of the profile says in its own words. English says every one

func (*Languages) Sources

func (l *Languages) Sources(cfg *config.Config, id string) []lang.Text

Where the words of the language of the profile come from, as a user reads each

type Pack

type Pack struct {
	// Id of the language, one of the bundled ones or a new one
	Language string
	// What a new language calls itself and whether it is written right to left. The bundled ones keep their own
	Endonym string
	RTL     bool
	// What brought it, as a user reads it, such as the extension of its name
	Source  lang.Text
	Catalog lang.Catalog
	// Fingerprint of what its words were read from, which changes once they do, so a language made with it is made again
	Version string
}

Words a language pack of an extension brings for a language. For a language Speaks, the pack holds words for texts icebath carries none for alone: a registrant leaves out what Replaces says, so no pack changes what icebath itself says in a language it speaks

type Packs

type Packs []Pack

A registrant whose packs are fixed once registered

func (Packs) Packs

func (p Packs) Packs(*config.Config) []Pack

type Problem

type Problem struct {
	// Where the catalog is, a file or a pack's source
	Where lang.Text
	// Language it is of
	Language string
	Text     lang.Text
}

Something wrong in a catalog, which the Doctor says: where it is and what

type Registrant

type Registrant interface {
	// Language packs of the profile of the settings, read quickly
	Packs(cfg *config.Config) []Pack
}

type Registry

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

func (*Registry) Host

func (r *Registry) Host() *Languages

func (*Registry) Packs

func (r *Registry) Packs(cfg *config.Config) []Pack

Every pack of the profile of the settings, in the order they were registered

func (*Registry) Register

func (r *Registry) Register(registrant Registrant)

type Words

type Words struct {
	Catalogs map[string]lang.Catalog
	Problems []Problem
	Files    string
}

Words of a folder of catalogs laid out as a profile's own, such as a language pack's: by language, what was wrong in them and left out, and a fingerprint of the names and versions of its files, which changes once they do

func ReadWords

func ReadWords(dir string, where lang.Text) Words

Words of a folder of catalogs as its files are now, where saying where they are as a user reads it

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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