File tree 2 files changed +14
-0
lines changed 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,8 @@ type Domain struct {
45
45
trBuffer * Translation
46
46
ctxBuffer string
47
47
refBuffer string
48
+
49
+ customPluralResolver func (int ) int
48
50
}
49
51
50
52
// Preserve MIMEHeader behaviour, without the canonicalisation
@@ -88,13 +90,21 @@ func NewDomain() *Domain {
88
90
return domain
89
91
}
90
92
93
+ func (do * Domain ) SetPluralResolver (f func (int ) int ) {
94
+ do .customPluralResolver = f
95
+ }
96
+
91
97
func (do * Domain ) pluralForm (n int ) int {
92
98
// do we really need locking here? not sure how this plurals.Expression works, so sticking with it for now
93
99
do .pluralMutex .RLock ()
94
100
defer do .pluralMutex .RUnlock ()
95
101
96
102
// Failure fallback
97
103
if do .pluralforms == nil {
104
+ if do .customPluralResolver != nil {
105
+ return do .customPluralResolver (n )
106
+ }
107
+
98
108
/* Use the Germanic plural rule. */
99
109
if n == 1 {
100
110
return 0
Original file line number Diff line number Diff line change @@ -85,6 +85,10 @@ func (po *Po) GetRefs(str string) []string {
85
85
return po .domain .GetRefs (str )
86
86
}
87
87
88
+ func (po * Po ) SetPluralResolver (f func (int ) int ) {
89
+ po .domain .customPluralResolver = f
90
+ }
91
+
88
92
func (po * Po ) Set (id , str string ) {
89
93
po .domain .Set (id , str )
90
94
}
You can’t perform that action at this time.
0 commit comments