func (po *Po) parsePluralID(l string) {
	po.domain.trBuffer.PluralID, _ = strconv.Unquote(strings.TrimSpace(strings.TrimPrefix(l, "msgid_plural")))
}
parsePluralID saves the plural id buffer from a line starting with "msgid_plural"
package gotext
import (
	"strconv"
	"strings"
)
type Po struct {
	Headers     HeaderMap
	Language    string
	PluralForms string
	domain *Domain
}
type parseState int
const (
	head parseState = iota
	msgCtxt
	msgID
	msgIDPlural
	msgStr
)
func NewPo() *Po {
	po := new(Po)
	po.domain = NewDomain()
	return po
}
func (po *Po) GetDomain() *Domain {
	return po.domain
}
func (po *Po) DropStaleTranslations() {
	po.domain.DropStaleTranslations()
}
func (po *Po) SetRefs(str string, refs []string) {
	po.domain.SetRefs(str, refs)
}
func (po *Po) GetRefs(str string) []string {
	return po.domain.GetRefs(str)
}
func (po *Po) Set(id, str string) {
	po.domain.Set(id, str)
}
func (po *Po) Get(str string, vars ...interface{}) string {
	return po.domain.Get(str, vars...)
}
func (po *Po) SetN(id, plural string, n int, str string) {
	po.domain.SetN(id, plural, n, str)
}
func (po *Po) GetN(str, plural string, n int, vars ...interface{}) string {
	return po.domain.GetN(str, plural, n, vars...)
}
func (po *Po) SetC(id, ctx, str string) {
	po.domain.SetC(id, ctx, str)
}
func (po *Po) GetC(str, ctx string, vars ...interface{}) string {
	return po.domain.GetC(str, ctx, vars...)
}
func (po *Po) SetNC(id, plural, ctx string, n int, str string) {
	po.domain.SetNC(id, plural, ctx, n, str)
}
func (po *Po) GetNC(str, plural string, n int, ctx string, vars ...interface{}) string {
	return po.domain.GetNC(str, plural, n, ctx, vars...)
}
func (po *Po) MarshalText() ([]byte, error) {
	return po.domain.MarshalText()
}
func (po *Po) MarshalBinary() ([]byte, error) {
	return po.domain.MarshalBinary()
}
func (po *Po) UnmarshalBinary(data []byte) error {
	return po.domain.UnmarshalBinary(data)
}
func (po *Po) ParseFile(f string) {
	data, err := getFileData(f)
	if err != nil {
		return
	}
	po.Parse(data)
}
func (po *Po) Parse(buf []byte) {
	if po.domain == nil {
		panic("NewPo() was not used to instantiate this object")
	}
	po.domain.trMutex.Lock()
	po.domain.pluralMutex.Lock()
	defer po.domain.trMutex.Unlock()
	defer po.domain.pluralMutex.Unlock()
	lines := strings.Split(string(buf), "\n")
	po.domain.trBuffer = NewTranslation()
	po.domain.ctxBuffer = ""
	po.domain.refBuffer = ""
	state := head
	for _, l := range lines {
		l = strings.TrimSpace(l)
		if !po.isValidLine(l) {
			po.parseComment(l, state)
			continue
		}
		if strings.HasPrefix(l, "msgctxt") {
			po.parseContext(l)
			state = msgCtxt
			continue
		}
		if strings.HasPrefix(l, "msgid") && !strings.HasPrefix(l, "msgid_plural") {
			po.parseID(l)
			state = msgID
			continue
		}
		if strings.HasPrefix(l, "msgid_plural") {
			po.parsePluralID(l)
			po.domain.pluralTranslations[po.domain.trBuffer.PluralID] = po.domain.trBuffer
			state = msgIDPlural
			continue
		}
		if strings.HasPrefix(l, "msgstr") {
			po.parseMessage(l)
			state = msgStr
			continue
		}
		if strings.HasPrefix(l, "\"") && strings.HasSuffix(l, "\"") {
			po.parseString(l, state)
			continue
		}
	}
	po.saveBuffer()
	po.domain.parseHeaders()
	po.Language = po.domain.Language
	po.PluralForms = po.domain.PluralForms
	po.Headers = po.domain.Headers
}
func (po *Po) saveBuffer() {
	if po.domain.ctxBuffer == "" {
		po.domain.translations[po.domain.trBuffer.ID] = po.domain.trBuffer
	} else {
		if _, ok := po.domain.contexts[po.domain.ctxBuffer]; !ok {
			po.domain.contexts[po.domain.ctxBuffer] = make(map[string]*Translation)
		}
		po.domain.contexts[po.domain.ctxBuffer][po.domain.trBuffer.ID] = po.domain.trBuffer
		if po.domain.trBuffer.ID != "" {
			po.domain.ctxBuffer = ""
		}
	}
	if po.domain.refBuffer == "" {
		po.domain.trBuffer = NewTranslation()
	} else {
		po.domain.trBuffer = NewTranslationWithRefs(strings.Split(po.domain.refBuffer, " "))
	}
}
func (po *Po) parseComment(l string, state parseState) {
	if len(l) > 0 && l[0] == '#' {
		if state == head {
			po.domain.headerComments = append(po.domain.headerComments, l)
		} else if len(l) > 1 {
			switch l[1] {
			case ':':
				if len(l) > 2 {
					po.domain.refBuffer = strings.TrimSpace(l[2:])
				}
			}
		}
	}
}
func (po *Po) parseContext(l string) {
	po.saveBuffer()
	po.domain.ctxBuffer, _ = strconv.Unquote(strings.TrimSpace(strings.TrimPrefix(l, "msgctxt")))
}
func (po *Po) parseID(l string) {
	po.saveBuffer()
	po.domain.trBuffer.ID, _ = strconv.Unquote(strings.TrimSpace(strings.TrimPrefix(l, "msgid")))
}