Understanding POT PO and MO Files

Gettext is an internationalization and localization (i18n) system commonly used for writing multilingual programs on Unix-like computer operating.When used in localization PO/Mo files are used.

PO file is Portable Object file

And MO File are binary  objects from the ready-converted .po files, so that gettext could translate the site.

Where are POT file is primary file called as Portable Object Template file.

So here how it goes Like Pot > PO >MO


You can always generate PO file from POT file and MO file directly from compiling PO file.

Understanding POT PO MO file
Understanding POT PO MO file

Software you may consider using to edit POT/PO/MO files:

  • Poedit (Mac)
  • GlotPress (web-based)
  • Launchpad (Ubuntu)
  • Pootle (web-based)
  • KBabel (Linux)
  • GNU Gettext (command shell)

Storing PO and MO files: Gettext only reads MO files , so you can store them in this location



Here xx_XX can be code for language _Country Code , For Example


some popular Locales are

  • en_US=English
  • ar=Arabic
  • bg_BG=Bulgarian
  • cs_CZ=Czech
  • el_GR=Greek
  • es_ES=Spanish
  • fr_FR=French
  • hi_IN=Hindi
  • hu_HU=Hungarian
  • hw=Hebrew
  • in_ID=Indonesian
  • it_IT=Italian
  • ja_JP=Japanese
  • ko_KR=Korean
  • nl_NL=Dutch
  • no_NO=Norwegian
  • pt_BR=Portuguese
  • ro_RO=Romanian
  • ru_RU=Russian
  • sk_SK=Slovak
  • th_TH=Thai
  • uk_UA=Ukrainian
  • vi_VN=Vietnamese
  • zh_CN=Chinese

So when you Open your myfile.pot in POedit and save as .po file. it will also compile a .mo file.

In any PHP file Gettext is going to read strings with following Syntax

__("Some Text Here");

_e(“Some Text Here”);

_(“Some Text Here”);


__('Some Text Here');

_e(‘Some Text Here’);

_(‘Some Text Here’);

And Read it from MO file

Where it was specified as

#: index.php:5
msgid "Some Text Here"
msgstr "Certains texte ici"

Let your script know to use Locale

bindtextdomain("default", "./locale/");
setlocale(LC_ALL,'en_US' );

default will be mo file name

so it looks like



Some times you make have this trouble

Question marks instead of some local characters in reading mo /po file

In that case you may need to set charset.

You can do it Via


bind_textdomain_codeset (domain, codeset);


bind_textdomain_codeset("default", 'UTF-8');

Understanding POT PO and MO Files
Tagged on:                         

Leave a Reply

Your email address will not be published.