locales

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: Apache-2.0 Imports: 3 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

Overview

Package locales says the hello example's messages in the language it shows.

Index

Constants

View Source
const Source = "en"

Source is the language the messages are written in.

Variables

View Source
var Catalog = i18n.NewCatalog("en", "zh-Hans")

Catalog holds the messages' languages: en, the source, zh-Hans, and those other packages supply.

View Source
var Parameters = map[string][]string{
	"Greeting": {"name"},
	"Said":     {"count"},
}

Parameters names the parameters of each message that has some, by its method, for the TSX declarations of the messages (tsx.RegisterMessages).

Functions

func AppName

func AppName(cx *core.Scope) string

AppName says "Hello" in the language the app shows under cx.

The app's name, which its packages list it under in each language.

func Greeting

func Greeting(cx *core.Scope, name string) string

Greeting says "Hello, {name}!" in the language the app shows under cx.

func NamePlaceholder

func NamePlaceholder(cx *core.Scope) string

NamePlaceholder says "Your name" in the language the app shows under cx.

func Said

func Said(cx *core.Scope, count int) string

Said says "{count, plural, =0 {Not said yet} one {Said # time} other {Said # times}}" in the language the app shows under cx.

How many times the button said hello.

func SayHello

func SayHello(cx *core.Scope) string

SayHello says "Say hello" in the language the app shows under cx.

func Supply

func Supply(lang string, t Translation)

Supply adds the messages t has in lang to the catalog, over its own. nsgo writes the calls, in the package that supplies them, which runs them as it initializes.

func World

func World(cx *core.Scope) string

World says "world" in the language the app shows under cx.

Who the greeting greets before anyone typed a name.

Types

type Messages

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

Messages say the messages in one language, their times in the hour cycle hc the user set; with mark, the source's with their arguments marked, which a pseudo locale transforms.

func For

func For(cx *core.Scope) Messages

For returns the messages in the language the app shows under cx (i18n.Language), their times as the user reads them; a binding that says them follows both as they change.

func In

func In(locale string) Messages

In returns the messages in the catalog's language that suits locale best, as zh-Hant suits zh-TW, else in the source language.

func (Messages) AppName

func (msgs Messages) AppName() string

AppName is the package's AppName in the language of msgs.

func (Messages) Greeting

func (msgs Messages) Greeting(name string) string

Greeting is the package's Greeting in the language of msgs.

func (Messages) NamePlaceholder

func (msgs Messages) NamePlaceholder() string

NamePlaceholder is the package's NamePlaceholder in the language of msgs.

func (Messages) Said

func (msgs Messages) Said(count int) string

Said is the package's Said in the language of msgs.

func (Messages) SayHello

func (msgs Messages) SayHello() string

SayHello is the package's SayHello in the language of msgs.

func (Messages) World

func (msgs Messages) World() string

World is the package's World in the language of msgs.

type Translation

type Translation struct {
	Texts    map[string]string
	Greeting func(name string) string
	Said     func(count int) string
}

Translation is a language's messages another package supplies: those without arguments in Texts, by key, and a function for each of the others; a key or a field left out leaves the message to the catalog.

Jump to

Keyboard shortcuts

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