1 // Copyright 2013 ChaiShushan <chaishushan{AT}gmail.com>. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 /* 6 Package mo provides support for reading and writing GNU MO file. 7 8 Examples: 9 import ( 10 "github.com/chai2010/gettext-go/mo" 11 ) 12 13 func main() { 14 moFile, err := mo.LoadFile("test.mo") 15 if err != nil { 16 log.Fatal(err) 17 } 18 fmt.Printf("%v", moFile) 19 } 20 21 GNU MO file struct: 22 23 byte 24 +------------------------------------------+ 25 0 | magic number = 0x950412de | 26 | | 27 4 | file format revision = 0 | 28 | | 29 8 | number of strings | == N 30 | | 31 12 | offset of table with original strings | == O 32 | | 33 16 | offset of table with translation strings | == T 34 | | 35 20 | size of hashing table | == S 36 | | 37 24 | offset of hashing table | == H 38 | | 39 . . 40 . (possibly more entries later) . 41 . . 42 | | 43 O | length & offset 0th string ----------------. 44 O + 8 | length & offset 1st string ------------------. 45 ... ... | | 46 O + ((N-1)*8)| length & offset (N-1)th string | | | 47 | | | | 48 T | length & offset 0th translation ---------------. 49 T + 8 | length & offset 1st translation -----------------. 50 ... ... | | | | 51 T + ((N-1)*8)| length & offset (N-1)th translation | | | | | 52 | | | | | | 53 H | start hash table | | | | | 54 ... ... | | | | 55 H + S * 4 | end hash table | | | | | 56 | | | | | | 57 | NUL terminated 0th string <----------------' | | | 58 | | | | | 59 | NUL terminated 1st string <------------------' | | 60 | | | | 61 ... ... | | 62 | | | | 63 | NUL terminated 0th translation <---------------' | 64 | | | 65 | NUL terminated 1st translation <-----------------' 66 | | 67 ... ... 68 | | 69 +------------------------------------------+ 70 71 The GNU MO file specification is at 72 http://www.gnu.org/software/gettext/manual/html_node/MO-Files.html. 73 */ 74 package mo 75