Documentation
¶
Overview ¶
Package pofile implements reading and writing of PO/POT files following the GNU gettext format specification.
Index ¶
- func LangNameNative(lang string) string
- func PluralFormsForLang(lang string) string
- type Entry
- type File
- func (f *File) EntryByMsgID(msgid string) *Entry
- func (f *File) FuzzyEntries() []*Entry
- func (f *File) HeaderField(name string) string
- func (f *File) SetHeaderField(name, value string)
- func (f *File) Stats() (total, translated, fuzzy, untranslated int)
- func (f *File) UntranslatedEntries() []*Entry
- func (f *File) Write(w io.Writer) error
- func (f *File) WriteFile(path string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LangNameNative ¶
LangNameNative returns the native name of a language.
func PluralFormsForLang ¶
PluralFormsForLang returns the standard Plural-Forms header for a language code.
Types ¶
type Entry ¶
type Entry struct {
// TranslatorComments are lines starting with "# " (translator comments).
TranslatorComments []string
// ExtractedComments are lines starting with "#." (extracted/automatic comments).
ExtractedComments []string
// References are source code locations, lines starting with "#:".
References []string
// Flags are format flags, lines starting with "#,".
Flags []string
// PreviousMsgID stores the previous msgid for fuzzy entries, lines starting with "#|".
PreviousMsgID string
// MsgCtxt is the message context (msgctxt).
MsgCtxt string
// MsgID is the untranslated string.
MsgID string
// MsgIDPlural is the untranslated plural string.
MsgIDPlural string
// MsgStr is the translated string (singular or the only form).
MsgStr string
// MsgStrPlural maps plural form index to translated string.
MsgStrPlural map[int]string
// Obsolete marks entries prefixed with "#~".
Obsolete bool
}
Entry represents a single translatable message in a PO file.
func MakeHeader ¶
MakeHeader creates a standard PO/POT file header.
func (*Entry) IsTranslated ¶
IsTranslated returns true if the entry has a non-empty translation.
type File ¶
type File struct {
// Header is the metadata entry (msgid "").
Header *Entry
// Entries are the translatable message entries.
Entries []*Entry
}
File represents a parsed PO/POT file.
func (*File) EntryByMsgID ¶
EntryByMsgID finds an entry by its msgid.
func (*File) FuzzyEntries ¶
FuzzyEntries returns entries marked as fuzzy.
func (*File) HeaderField ¶
HeaderField returns a header field value by name.
func (*File) SetHeaderField ¶
SetHeaderField sets a header field value.
func (*File) UntranslatedEntries ¶
UntranslatedEntries returns entries that have no translation and are not fuzzy.