13

I started trying to translate a few of the most used text entries in a C program using gettext, but when digging into this I got a little bit confused about all the different file formats since there seems to be some overlap in functionality?

I would like get an overview of the different formats

  • .po
  • .pot
  • .mo
  • .gmo
  • (other formats I have excluded?)

and learn

  • What is the normal workflow?
  • What does this file format contain?
  • What tools are typically used?
  • What "opposite" direction conversions are possible (1)?

(1) I know that msgunfmt can convert from .mo to .po, but since .mo is the final end format I assume this is not a lossless process. I.e. if I convert from hello1.mo to hello2.po and then convert from hello2.po to hello3.mo, I assume that hello1.mo and hello3.mo will contain identical language strings but that some meta information will be lost along the way, right?

hlovdal
  • 26,565
  • 10
  • 94
  • 165

1 Answers1

14

I could be wrong but:

.pot - human readable gettext template file - this what you would give to translator (person?).

.po - human readable gettext translated file based on POT - this is what translator gives you back.

.mo - machine readable code (bytecode?) to be used by PHP when doing actual translation. This format is what you would feed to php. It's a generic format understood by most programs but it might not support all gnu gettext features. This is where gmo comes in place.

.gmo - files ending with .gmo are really MO files, when it is known that these files use the GNU format.


You can use poedit to handle .pot -> .po -> .mo

more info

P.S. with that being said - only programmers would call formats like PO or XML a human-readable. also - you probably won't need to convert .mo to .po...well..At least this doesn't seem like a common scenario to me :)

Stann
  • 13,518
  • 19
  • 65
  • 73
  • 3
    Upvote just for "only programmers would call formats like PO or XML a human-readable", often forgotten but very true – jforberg Jul 10 '14 at 13:46