i18n

package
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package i18n is a platform module: translations of API responses and error messages, ported from taply. Requires postgres and api.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func From

func From(app *platform.App) *i18nx.Client

From returns the translations client from the container.

func SkipTranslation

func SkipTranslation(app *platform.App, fn func(ctx context.Context) bool)

SkipTranslation turns response substitution off for the calls fn picks — taply does it for tablets of a restaurant with translations disabled. Error messages are still translated.

Types

type Config

type Config struct {
	DefaultLocale i18nx.Locale   // language of the base columns and the fallback
	Locales       []i18nx.Locale // languages the API answers in
}

Config holds module settings. Load fills it from the environment; the platform generator writes the Load call into the project's config.gen.go.

func Load

func Load(l *confx.Loader) Config

Load reads the module settings from environment variables.

type Module

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

Module implements platform.Module.

func New

func New(cfg Config, opts ...Option) *Module

New creates the module.

func (*Module) Init

func (m *Module) Init(ctx context.Context, app *platform.App) error

Init creates the translations table, loads the static translations and puts the translation of requests and responses into the API.

func (*Module) Name

func (m *Module) Name() string

type Option

type Option func(*Module)

Option configures the module.

func WithMessages

func WithMessages(yaml string) Option

WithMessages gives the module the static translations of the project. The generated wiring passes the embedded i18n/messages.yaml.

Jump to

Keyboard shortcuts

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