- Add i18n.RegisterLocales(fsys, dir) for packages to register translations
- Locales are automatically loaded when i18n.Init() is called
- Fix gram.word.* loading bug (strings were in wrong switch case)
- Fix loadJSON to merge messages instead of replacing
- Add common.* keys to base locale (labels, flags, progress, etc.)
- Add pkg/php/locales with PHP-specific translations
- pkg/php/i18n.go registers locales via init()
This enables the idiomatic pattern where packages register their
locale files and they're automatically loaded by the i18n system.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- LoadFS: Use path.Join instead of filepath.Join for fs.FS compatibility
- AddHandler: Document handler chain lock behavior
- getEffectiveFormality: Support string values ("formal", "informal")
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- service.go: Simplify Default() to just call Init() (sync.Once handles idempotency)
- service.go: Add nil check to SetDefault() with panic
- service.go: Add documentation for ModeStrict panic behavior
- loader.go: Add LanguagesErr() to expose directory scan errors
- loader.go: Use path.Join instead of filepath.Join for fs.FS compatibility
- transform.go: Add uint, uint8-64, int8, int16 support to type converters
- grammar.go: Replace deprecated strings.Title with unicode-aware implementation
- i18n_test.go: Add comprehensive concurrency tests with race detector
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- hooks.go: Use atomic.Value for missingKeyHandler global
- loader.go: Use sync.Once for FSLoader.Languages() caching
- service.go: Use atomic.Pointer[Service] for defaultService
All globals that could race between goroutines now use proper
synchronization primitives.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add NewWithLoader(loader, opts...) for custom storage backends
- Add Option type with WithFallback, WithFormality, WithHandlers,
WithDefaultHandlers, WithMode, WithDebug options
- Update New() and NewWithFS() to accept options
- Add loader field to Service struct
- Remove NewSubject() alias (use S() instead)
- Add tests for new options and NewWithLoader
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Article("") now returns "" for consistency with other grammar
functions (PastTense, Gerund, PluralForm, Label all return "")
- Add doc comment to getMessage() for consistency with other
internal helpers
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add explicit nil checks to toInt, toInt64, toFloat64 for consistency
- Standardize error messages to use %q for user-provided strings
- Export GetGrammarData for symmetry with SetGrammarData
- Standardize String() doc comments to "the TypeName" pattern
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Move all exported types to interfaces.go for consistent organisation.
Rename interface.go → interfaces.go.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Move Service struct, methods, constructors, and singleton management
to dedicated file for better code organization.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>