...
1
2
3
4
5 package mo
6
7 import (
8 "bytes"
9 "fmt"
10 )
11
12
13
14
15
16
17 type Message struct {
18 MsgContext string
19 MsgId string
20 MsgIdPlural string
21 MsgStr string
22 MsgStrPlural []string
23 }
24
25
26 func (p Message) String() string {
27 var buf bytes.Buffer
28 fmt.Fprintf(&buf, "msgid %s", encodePoString(p.MsgId))
29 if p.MsgIdPlural != "" {
30 fmt.Fprintf(&buf, "msgid_plural %s", encodePoString(p.MsgIdPlural))
31 }
32 if p.MsgStr != "" {
33 fmt.Fprintf(&buf, "msgstr %s", encodePoString(p.MsgStr))
34 }
35 for i := 0; i < len(p.MsgStrPlural); i++ {
36 fmt.Fprintf(&buf, "msgstr[%d] %s", i, encodePoString(p.MsgStrPlural[i]))
37 }
38 return buf.String()
39 }
40
41 func (m_i *Message) less(m_j *Message) bool {
42 if a, b := m_i.MsgContext, m_j.MsgContext; a != b {
43 return a < b
44 }
45 if a, b := m_i.MsgId, m_j.MsgId; a != b {
46 return a < b
47 }
48 if a, b := m_i.MsgIdPlural, m_j.MsgIdPlural; a != b {
49 return a < b
50 }
51 return false
52 }
53
View as plain text