contracttests

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunI18nContract

func RunI18nContract(t *testing.T, subject I18nContractSubject)

RunI18nContract executes shared i18n contract checks for adapter implementations.

Types

type I18nContractAdapter

type I18nContractAdapter interface {
	DefaultLanguage() string
	SupportedLanguages() []string
	NormalizeLanguage(raw string) string
	T(ctx context.Context, key string, templateData ...map[string]any) string
	TC(ctx context.Context, key string, count any, templateData ...map[string]any) string
	TS(ctx context.Context, key string, choice string, templateData ...map[string]any) string
}

I18nContractAdapter is the minimal adapter surface required by core i18n consumers.

type I18nContractSubject

type I18nContractSubject struct {
	Name               string
	Build              func(t *testing.T) I18nContractAdapter
	KnownDefaultKey    string
	KnownDefaultResult string
}

I18nContractSubject describes one adapter implementation to validate.

Jump to

Keyboard shortcuts

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