refactor(i18n): move Message struct to interface.go
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
1477bceb95
commit
0955847661
2 changed files with 12 additions and 12 deletions
|
|
@ -37,18 +37,6 @@ import (
|
||||||
//go:embed locales/*.json
|
//go:embed locales/*.json
|
||||||
var localeFS embed.FS
|
var localeFS embed.FS
|
||||||
|
|
||||||
// Message represents a translation - either a simple string or plural forms.
|
|
||||||
// Supports full CLDR plural categories for languages with complex plural rules.
|
|
||||||
type Message struct {
|
|
||||||
Text string // Simple string value (non-plural)
|
|
||||||
Zero string // count == 0 (Arabic, Latvian, Welsh)
|
|
||||||
One string // count == 1 (most languages)
|
|
||||||
Two string // count == 2 (Arabic, Welsh)
|
|
||||||
Few string // Small numbers (Slavic: 2-4, Arabic: 3-10)
|
|
||||||
Many string // Larger numbers (Slavic: 5+, Arabic: 11-99)
|
|
||||||
Other string // Default/fallback form
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsPlural returns true if this message has any plural forms.
|
// IsPlural returns true if this message has any plural forms.
|
||||||
func (m Message) IsPlural() bool {
|
func (m Message) IsPlural() bool {
|
||||||
return m.Zero != "" || m.One != "" || m.Two != "" ||
|
return m.Zero != "" || m.One != "" || m.Two != "" ||
|
||||||
|
|
|
||||||
|
|
@ -108,3 +108,15 @@ type MissingKeyAction = MissingKey
|
||||||
// rule := i18n.GetPluralRule("ru")
|
// rule := i18n.GetPluralRule("ru")
|
||||||
// category := rule(5) // Returns PluralMany for Russian
|
// category := rule(5) // Returns PluralMany for Russian
|
||||||
type PluralRule func(n int) PluralCategory
|
type PluralRule func(n int) PluralCategory
|
||||||
|
|
||||||
|
// Message represents a translation - either a simple string or plural forms.
|
||||||
|
// Supports full CLDR plural categories for languages with complex plural rules.
|
||||||
|
type Message struct {
|
||||||
|
Text string // Simple string value (non-plural)
|
||||||
|
Zero string // count == 0 (Arabic, Latvian, Welsh)
|
||||||
|
One string // count == 1 (most languages)
|
||||||
|
Two string // count == 2 (Arabic, Welsh)
|
||||||
|
Few string // Small numbers (Slavic: 2-4, Arabic: 3-10)
|
||||||
|
Many string // Larger numbers (Slavic: 5+, Arabic: 11-99)
|
||||||
|
Other string // Default/fallback form
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue