Releases: kaptinlin/jsonschema
Releases · kaptinlin/jsonschema
v0.8.0
Localization moved to the optional i18n subpackage
The root package no longer imports any translation framework. Pure validation users pay zero Intl compile, link, and binary cost — 28 transitive packages dropped from the root import graph, and not a single byte of locale data ends up in your binary unless you opt in.
Localization is now opt-in through the consumer-side Translator interface:
type Translator interface {
Translate(code string, params map[string]any) (message string, ok bool)
}The i18n subpackage provides the built-in 9-locale implementation (backed by go-i18n); or implement the one-method interface yourself with any backend.
Migration
| Before | After |
|---|---|
jsonschema.I18n() + bundle.NewLocalizer("zh-Hans") |
i18n.New("zh-Hans") — import github.com/kaptinlin/jsonschema/i18n |
err.Localize(localizer) |
err.Localize(translator) |
result.ToLocalizeList(localizer, ...) |
result.ToLocalizedList(translator, ...) |
result.DetailedErrors(localizer) |
result.LocalizedDetailedErrors(translator) |
result.DetailedErrors() |
unchanged — always English, no arguments |
import (
"github.com/kaptinlin/jsonschema"
"github.com/kaptinlin/jsonschema/i18n"
)
zh, err := i18n.New("zh-Hans") // one translator per locale; unknown locale errors here
if err != nil { ... }
for path, msg := range result.LocalizedDetailedErrors(zh) {
fmt.Println(path, msg)
}Behavior
- Fallback semantics unchanged: a
niltranslator or a missing translation falls back to the built-in English message — localization never fails. - Same 9 built-in locales:
en,de-DE,es-ES,fr-FR,ja-JP,ko-KR,pt-BR,zh-Hans,zh-Hant. i18n.Newrejects unknown locales withErrUnsupportedLocaleinstead of silently falling back to English.
Dependencies
go-i18nupgraded to v0.5.0 (now usesmessageformat-go/mf1v0.7.0).
Full Changelog: v0.7.18...v0.8.0
v0.7.17
v0.7.15
v0.7.14
What's Changed
Changed
- Streamlined validation, struct object handling, tag parsing, and schemagen internals without changing the public API.
- Adopted modern Go collection and iteration helpers across internal paths.
- Updated Go toolchain metadata, golangci-lint, and core library dependencies.
- Dropped markdownlint tooling from the repository workflow.
Documentation
- Clarified validation entry points, defaults behavior, and loader safety.