localization

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package localization owns locale request resolution and the logical single-locale/canonical-storage transform shared by operation engines and strict store fixtures.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyLocaleIssues

func CopyLocaleIssues(fields []schema.Field, values store.Values) []schema.Issue

CopyLocaleIssues rejects structured localized copies that cannot match rows back to their canonical storage counterparts. Positional matching would let stale or reordered input overwrite non-localized siblings, so row keys are a safety requirement for non-localized arrays and blocks with localized descendants.

func LocalizedValues

func LocalizedValues(fields []schema.Field, values store.Values) store.Values

LocalizedValues extracts only localized authored values from one projected document. Row identity and block discriminators are retained so a copy-to-locale update can merge nested values without replacing shared structure or non-localized siblings.

func MergeStoragePatch

func MergeStoragePatch(fields []schema.Field, current, patch store.Values) store.Values

MergeStoragePatch combines partial locale maps during an update.

func MergeStorageUpdate

func MergeStorageUpdate(fields []schema.Field, current, patch store.Values) store.Values

MergeStorageUpdate expands submitted structured fields against their current canonical value while keeping the update limited to top-level fields present in the patch. PostgreSQL stores groups, arrays, and blocks as one JSON value, so this makes its patch semantics match stores that merge those values in memory: omitted nested fields are preserved, explicit nulls still clear, and keyed row lists may still remove whole rows by omitting the row itself.

func ParseFallbackQuery

func ParseFallbackQuery(value string) ([]schema.LocaleCode, bool, error)

ParseFallbackQuery accepts Payload-compatible disable tokens or a comma-separated fallback chain. A nil slice means no explicit override.

func ProjectDocument

func ProjectDocument(document store.Document, fields []schema.Field, selection Selection) store.Document

ProjectDocument selects localized values for hooks and API output. All locale requests retain canonical locale maps.

func StoragePatch

func StoragePatch(fields []schema.Field, values store.Values, selection Selection) (store.Values, error)

StoragePatch turns selected-locale authored input into the canonical locale map expected by stores without adding or deleting values for other locales.

Types

type Selection

type Selection struct {
	Locale     schema.LocaleCode
	Chain      []schema.LocaleCode
	All        bool
	Configured []schema.LocaleCode
}

Selection is one validated request locale and its effective fallback chain.

func Resolve

func Resolve(settings *schema.LocalizationSettings, locale string, explicitFallback []schema.LocaleCode, disableFallback, all bool) (Selection, error)

Resolve validates request locale input. ExplicitFallback replaces configured fallback behavior. DisableFallback prevents both locale and default fallback.

Jump to

Keyboard shortcuts

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