Documentation ¶
Overview ¶
Package mo provides support for reading and writing GNU MO file.
Examples:
import ( "code.google.com/p/gettext-go/gettext/mo" ) func main() { moFile, err := mo.Load("test.mo") if err != nil { log.Fatal(err) } fmt.Printf("%v", moFile) }
GNU MO file struct:
byte +------------------------------------------+ 0 | magic number = 0x950412de | | | 4 | file format revision = 0 | | | 8 | number of strings | == N | | 12 | offset of table with original strings | == O | | 16 | offset of table with translation strings | == T | | 20 | size of hashing table | == S | | 24 | offset of hashing table | == H | | . . . (possibly more entries later) . . . | | O | length & offset 0th string ----------------. O + 8 | length & offset 1st string ------------------. ... ... | | O + ((N-1)*8)| length & offset (N-1)th string | | | | | | | T | length & offset 0th translation ---------------. T + 8 | length & offset 1st translation -----------------. ... ... | | | | T + ((N-1)*8)| length & offset (N-1)th translation | | | | | | | | | | | H | start hash table | | | | | ... ... | | | | H + S * 4 | end hash table | | | | | | | | | | | | NUL terminated 0th string <----------------' | | | | | | | | | NUL terminated 1st string <------------------' | | | | | | ... ... | | | | | | | NUL terminated 0th translation <---------------' | | | | | NUL terminated 1st translation <-----------------' | | ... ... | | +------------------------------------------+
The GNU MO file specification is at http://www.gnu.org/software/gettext/manual/html_node/MO-Files.html.
Index ¶
Constants ¶
const ( MoHeaderSize = 28 MoMagicLittleEndian = 0x950412de MoMagicBigEndian = 0xde120495 EotSeparator = "\x04" // msgctxt and msgid separator NulSeparator = "\x00" // msgid and msgstr separator )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type File ¶
type File struct { MagicNumber uint32 MajorVersion uint16 MinorVersion uint16 MsgIdCount uint32 MsgIdOffset uint32 MsgStrOffset uint32 HashSize uint32 HashOffset uint32 MimeHeader Header Messages []Message }
File represents an MO File.
See http://www.gnu.org/software/gettext/manual/html_node/MO-Files.html
type Header ¶
type Header struct { ProjectIdVersion string // Project-Id-Version: PACKAGE VERSION ReportMsgidBugsTo string // Report-Msgid-Bugs-To: FIRST AUTHOR <EMAIL@ADDRESS> POTCreationDate string // POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE PORevisionDate string // PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE LastTranslator string // Last-Translator: FIRST AUTHOR <EMAIL@ADDRESS> LanguageTeam string // Language-Team: golang-china Language string // Language: zh_CN MimeVersion string // MIME-Version: 1.0 ContentType string // Content-Type: text/plain; charset=UTF-8 ContentTransferEncoding string // Content-Transfer-Encoding: 8bit PluralForms string // Plural-Forms: nplurals=2; plural=n == 1 ? 0 : 1; XGenerator string // X-Generator: Poedit 1.5.5 UnknowFields map[string]string }
Header is the initial comments "SOME DESCRIPTIVE TITLE", "YEAR" and "FIRST AUTHOR <EMAIL@ADDRESS>, YEAR" ought to be replaced by sensible information.
See http://www.gnu.org/software/gettext/manual/html_node/Header-Entry.html#Header-Entry
type Message ¶
type Message struct { MsgContext string // msgctxt context MsgId string // msgid untranslated-string MsgIdPlural string // msgid_plural untranslated-string-plural MsgStr string // msgstr translated-string MsgStrPlural []string // msgstr[0] translated-string-case-0 }
A MO file is made up of many entries, each entry holding the relation between an original untranslated string and its corresponding translation.
See http://www.gnu.org/software/gettext/manual/html_node/MO-Files.html