doc.go 3.4 KB

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