enums

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: 9 Imported by: 0

Documentation

Overview

Package enums is a platform module: the catalog of the enums of the project served to clients, as taply's GetEnums does, with descriptions translated when i18n is enabled. Requires api.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func From

func From(app *platform.App) enumx.Catalog

From returns the catalog from the container.

func Translate

func Translate(c enumx.Catalog, client *i18nx.Client, locale i18nx.Locale) enumx.Catalog

Translate returns the catalog with its descriptions in a locale. The keys are enum.<entity>, enum.<entity>.<enum> and enum.<entity>.<enum>.<value>; a missing translation keeps the description from the code.

Types

type Config

type Config struct {
	Path string // where the catalog is served
}

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(_ context.Context, app *platform.App) error

Init puts the catalog into the container and serves it.

func (*Module) Name

func (m *Module) Name() string

type Option

type Option func(*Module)

Option configures the module.

func WithCatalog

func WithCatalog(c enumx.Catalog) Option

WithCatalog gives the module the generated catalog of the project.

Jump to

Keyboard shortcuts

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