Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the different gettext file formats used for?

Tags:

gettext

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?

like image 414
hlovdal Avatar asked Dec 01 '10 22:12

hlovdal


People also ask

What is gettext used for?

In computing, gettext is an internationalization and localization (i18n and l10n) system commonly used for writing multilingual programs on Unix-like computer operating systems. One of the main benefits of gettext is that it separates programming from translating.

What are Po and mo files?

po files means Portable Object, to distinguish it from . mo files, where MO stands for Machine Object.

What is gettext package?

gettext utilities are a set of tools that provides a framework to help other packages produce multi-lingual messages. The minimum version of the gettext utilities supported is 0.19.

What is gettext in Python?

The gettext module provides internationalization (I18N) and localization (L10N) services for your Python modules and applications. It supports both the GNU gettext message catalog API and a higher level, class-based API that may be more appropriate for Python files.


1 Answers

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 :)

like image 187
Stann Avatar answered Dec 18 '22 09:12

Stann