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.
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
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
msgid "Some Text Here"
msgstr "Certains texte ici"
Let your script know to use Locale
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);