Translation files .mo and .po

First thing you have to think about when creating anything, is your audience. Usually people, who will look and try to comprehend your work. And when we are talking about computer stuff, bigger part of comprehension is made through text. And the best way is to speak your audience’s native language. And I would like to describe one approach to managing translations. One translation is usually pair of two sentences, or some kind of ID and sentence. They are usually stored in huge pile of translation files and is difficult to maintain them.

Imagine GNU's Not Unix or a herd of gnus (yep, like horses)

Imagine GNU’s Not Unix or a herd of gnus (yep, like horses)

Main part of Linux (lets say open source) world found its way for managing translations. Current holy grail is named Gettext and is used not only in operating systems. You can manage translations with Gettext also in e.g. Gimp (even in a small plugins like my selection tool Laso) or WordPress.

Practical way to .mo and .po

These files are also called gettext catalogs.

.mo – a binary file (for computers) containing translations

.po – a text file  (for humans) containing translations

You usually care only about .po files. Conversion between .po and .mo file is possible in both directions.

msgid “Native language”
msgstr “La langue maternelle”

msgid “Translation files .mo and .po”
msgstr “Les fichiers de traduction .mo et. .po”

msgid “How to create translation”
msgstr “Comment créer traduction”

Example of .po file and corresponding .mo translation file.

Binary translation file

Binary translation file

Main steps to translation files

  1. Create stuff (e.g. program) that needs translation
  2. Generate .po file from source codes
    1. Mark all strings for translation by defined function (usually _() )
    2. Use directly Gettext, or easier program PoEdit (wizard from menu File > New catalog)
  3. Generate .mo file from .po file
    1. Visit online converter http://tools.konstruktors.com/
    2. Upload .po file to second section
    3. Download created .mo translation file
  4. Spread your translations

I hope this little howto for translation files could be useful. Broader explanation could be found in manual files for Gettext, or PoEdit.

Detailed introduction (and one of the best) is located at http://flossvalley.blogspot.cz/2008/07/quick-and-dirty-guide-to-poedit.html.

Spread the word...Email this to someoneTweet about this on TwitterShare on FacebookShare on Google+Share on LinkedInShare on Tumblr
Posted in IT Tagged with: , , ,
5 comments on “Translation files .mo and .po
  1. kdjsjh43jj says:

    Aw, this was a very good post. Spending some time and actual effort to make a great article… but what can I say… I put things off a lot and never seem to get anything done.

  2. I reckon something genuinely interesting about your site so I saved to bookmarks .

  3. I gotta favorite this internet site it seems very beneficial invaluable

  4. XRumerTest says:

    Hello. And Bye.

  5. Nice topic. i think you should write something more about this so that can help us more to know about this.

Leave a Reply to Elbert Laconte Cancel reply

Your email address will not be published. Required fields are marked *

*