Documentation
¶
Index ¶
- func ExtractICUArguments(s string) []string
- func ExtractPlaceholders(s string) []string
- func ExtractPlaceholdersFor(ctx context.Context, s string, options Options) ([]string, error)
- func ExtractTags(s string) []string
- func HasBalancedBraces(s string) bool
- func LooksLikeICU(s string) bool
- func MarkdownLinkDestinations(s string) []string
- type Issue
- type MarkdownLink
- type Options
- type Pair
- type Result
- type Service
- type Severity
- type TagToken
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractICUArguments ¶
ExtractICUArguments returns real argument names, including nested/simple ones. Malformed messages return no arguments; validation reports the parse error.
func ExtractPlaceholders ¶
ExtractPlaceholders returns unique placeholder tokens found in s.
func ExtractPlaceholdersFor ¶ added in v0.16.0
ExtractPlaceholdersFor uses the same syntax policy as validation, including ICU parsing.
func ExtractTags ¶
ExtractTags returns the unique normalized HTML-like tags in s.
func HasBalancedBraces ¶
HasBalancedBraces is retained for callers that only need a lexical brace check. Actual message validation uses parseICU, including apostrophe quoting.
func LooksLikeICU ¶
LooksLikeICU reports whether a message contains an ICU formatted argument.
func MarkdownLinkDestinations ¶
MarkdownLinkDestinations returns unique Markdown link destinations in s.
Types ¶
type Issue ¶
type Issue struct {
Scope string `json:"scope,omitzero" jsonschema:"source, target, or policy; source failures do not establish target defects"`
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 ¶
type MarkdownLink struct {
Raw string `json:"raw"`
Text string `json:"text"`
Destination string `json:"destination"`
}
MarkdownLink represents a Markdown inline link.
func ExtractMarkdownLinks ¶
func ExtractMarkdownLinks(s string) []MarkdownLink
ExtractMarkdownLinks returns Markdown inline links found in s.
type Pair ¶
type Pair struct {
Options Options `json:"-"`
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 (*Service) ValidatePair ¶
ValidatePair validates a source and target translation pair.
func (*Service) ValidatePairContext ¶ added in v0.16.0
ValidatePairContext validates a pair with cancellation-aware ICU parsing.
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 ¶
ExtractTagTokens returns normalized tag tokens found in s.