i18n

package
v0.0.0-...-7fbf2ce Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: GPL-3.0 Imports: 5 Imported by: 0

README

i18n

Localization support for the Vanilla OS SDK.

Extract strings

To extract strings from the source code, we use the xspreak tool. Can be installed with:

go install github.com/vorlif/xspreak@latest

To extract the POT, run:

xspreak -D path/to/source/ -p path/to/source/locale

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLocalizer

func NewLocalizer(localeFS embed.FS, defaultDomain string, locale string) (*spreak.Localizer, error)

NewLocalizer creates a new localizer for the application, the localizer is used to localize strings in the application. The localizer requires the application and the locale to be passed in, the locale is the language the user wants to use. If the locale is not found or is empty, the localizer will default to English, assuming it as the fallback.

Example:

t, err := i18n.NewLocalizer(app, "")
if err != nil {
	fmt.Printf("Error: %v\n", err)
	return
}
fmt.Println(t.Get("I am Batman!"))

Types

This section is empty.

Jump to

Keyboard shortcuts

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