pattern

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package pattern parses brace-delimited formatter patterns.

It provides the small tokenizer used by ECMA-402 partition algorithms before formatter packages substitute localized field values.

Only internal ECMA-402 and formatter code should use this package; public callers receive already formatted strings or parts.

Package pattern parses generated CLDR placeholder patterns.

Index

Constants

View Source
const Literal = "literal"

Literal is the part type for raw pattern text.

Variables

View Source
var ErrInvalid = errors.New("invalid pattern")

ErrInvalid classifies malformed placeholder patterns.

Functions

func FormatIndexed

func FormatIndexed(text string, values ...string) string

FormatIndexed replaces numeric placeholders with the corresponding value.

Types

type Part

type Part struct {
	Type  string
	Value string
}

Part is one literal or placeholder segment of a generated pattern.

type Pattern

type Pattern []Part

Pattern is a parsed sequence of placeholder pattern parts.

func Partition

func Partition(text string) (Pattern, error)

Partition splits text into literal and placeholder parts.

Jump to

Keyboard shortcuts

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