localecontent

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultFlag marks the fallback locale bucket inside AdAsset.context.
	DefaultFlag = "_default"
	// AnyLanguageCode is the legacy locale key for "any language".
	AnyLanguageCode = "**"
)

Variables

This section is empty.

Functions

func Fields

func Fields(context map[string]any, lang string) map[string]any

Fields returns the flattened field map for lang (merged with default when a non-default locale matches). Empty lang uses the default locale.

func FieldsOf

func FieldsOf(r Result, lang string) map[string]any

FieldsOf resolves lang against an already-split Result.

func Item

func Item(context map[string]any, lang, name string) any

Item returns a single field from the resolved locale map, then a top-level primitive on the raw context (legacy iframe_url / content).

func ItemOf

func ItemOf(r Result, context map[string]any, lang, name string) any

ItemOf looks up name in FieldsOf, then in raw top-level primitives.

Types

type Result

type Result struct {
	Locales       map[string]map[string]any
	DefaultLocale string
	DefaultFields map[string]any
}

Result is a pre-split AdAsset.context: per-locale field maps plus the default locale extracted once so serving does not scan for _default.

func Split

func Split(context map[string]any) Result

Split extracts locale buckets and the default locale from a raw context map. Nested context is detected when at least one top-level value is an object. Legacy flat maps ({title, description}) become DefaultFields with no locales.

Jump to

Keyboard shortcuts

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