Commit graph

3 commits

Author SHA1 Message Date
Snider
67e7e552f3 refactor(i18n): implement extensible handler chain architecture
Refactor the i18n package for extensibility without breaking changes:

- Add KeyHandler interface for pluggable namespace handlers
- Add Loader interface for format-agnostic translation loading
- Add TranslationContext for translation disambiguation
- Implement 6 built-in handlers (Label, Progress, Count, Done, Fail, Numeric)
- Update T() to use handler chain instead of hardcoded logic
- Add handler management methods (AddHandler, PrependHandler, ClearHandlers)

File reorganisation:
- types.go: all type definitions
- loader.go: Loader interface + FSLoader (from mutate.go, checks.go)
- handler.go: KeyHandler interface + built-in handlers
- context.go: TranslationContext + C() builder
- hooks.go: renamed from actions.go
- service.go: merged interfaces.go content

Deleted: interfaces.go, mode.go, mutate.go, checks.go

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 18:42:41 +00:00
Snider
7b9f23dd9e refactor(i18n): remove deprecated backwards-compat code
Remove since this is a new package with no external users:
- SetActionHandler() - use OnMissingKey() instead
- MissingKeyAction type alias - use MissingKey instead

Update tests to use current API.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 17:27:47 +00:00
Snider
002f8c7813 refactor(i18n): extract action handlers to actions.go
Move handler functions from mode.go to actions.go:
- OnMissingKey, SetActionHandler, dispatchMissingKey

mode.go now contains only Mode type and constants.
interface.go keeps all types/interfaces.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 17:04:21 +00:00