validate

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractICUArguments

func ExtractICUArguments(s string) []string

ExtractICUArguments returns unique ICU argument names found in s.

func ExtractPlaceholders

func ExtractPlaceholders(s string) []string

ExtractPlaceholders returns unique placeholder tokens found in s.

func ExtractTags

func ExtractTags(s string) []string

ExtractTags returns the unique normalized HTML-like tags in s.

func HasBalancedBraces

func HasBalancedBraces(s string) bool

HasBalancedBraces reports whether braces in s are balanced.

func LooksLikeICU

func LooksLikeICU(s string) bool

LooksLikeICU reports whether s appears to contain an ICU message.

func MarkdownLinkDestinations

func MarkdownLinkDestinations(s string) []string

MarkdownLinkDestinations returns unique Markdown link destinations in s.

Types

type Issue

type Issue struct {
	Code      string   `json:"code"`
	Message   string   `json:"message"`
	Severity  Severity `json:"severity"`
	Locale    string   `json:"locale,omitzero"`
	Namespace string   `json:"namespace,omitzero"`
	Key       string   `json:"key,omitzero"`
}

Issue describes one validation finding.

type MarkdownLink struct {
	Raw         string `json:"raw"`
	Text        string `json:"text"`
	Destination string `json:"destination"`
}

MarkdownLink represents a Markdown inline link.

func ExtractMarkdownLinks(s string) []MarkdownLink

ExtractMarkdownLinks returns Markdown inline links found in s.

type Pair

type Pair struct {
	SourceLocale string `json:"sourceLocale,omitzero"`
	Locale       string `json:"locale,omitzero"`
	Namespace    string `json:"namespace,omitzero"`
	Key          string `json:"key,omitzero"`
	Source       string `json:"source"`
	Target       string `json:"target"`
}

Pair contains a source string and target translation to validate.

type Result

type Result struct {
	OK       bool    `json:"ok"`
	Issues   []Issue `json:"issues,omitzero"`
	Warnings []Issue `json:"warnings,omitzero"`
}

Result contains validation issues and warnings.

type Service

type Service struct{}

Service validates translated strings.

func NewService

func NewService() *Service

NewService creates a translation validation service.

func (*Service) ValidatePair

func (s *Service) ValidatePair(pair Pair) Result

ValidatePair validates a source and target translation pair.

func (*Service) ValidateStrings

func (s *Service) ValidateStrings(source string, target string) Result

ValidateStrings validates source and target translation strings.

type Severity

type Severity string

Severity classifies a validation issue as an error or warning.

const (
	SeverityError   Severity = "error"
	SeverityWarning Severity = "warning"
)

Validation severities.

type TagToken

type TagToken struct {
	Raw         string `json:"raw"`
	Name        string `json:"name"`
	Closing     bool   `json:"closing,omitzero"`
	SelfClosing bool   `json:"selfClosing,omitzero"`
	Normalized  string `json:"normalized"`
}

TagToken represents an HTML-like tag found in a translation string.

func ExtractTagTokens

func ExtractTagTokens(s string) []TagToken

ExtractTagTokens returns normalized tag tokens found in s.

Jump to

Keyboard shortcuts

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