Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I create an .mo file for Wordpress

I have some .po files for Wordpress and i want to create .mo files.

How can i do this?

like image 630
Peter Avatar asked Dec 21 '10 13:12

Peter


People also ask

What are .MO files in WordPress?

The MO file includes the exact same contents as PO file. The two files differ in their format. While a PO file is a text file and is easy for humans to read, MO files are compiled and are easy for computers to read. Your web server will use the MO file to display the translations.

What is a .MO file?

Binary data file that contains object data referenced by a program; typically used to translate program code; may be loaded or imported into the GNU gettext program. Since MO files are binary in nature, they are not human readable like . PO files.


1 Answers

Linux

In Linux, you can just run this in Terminal:

msgcat yourFile.po | msgfmt -o generatedFile.mo - 

or

msgfmt -o generatedFile.mo yourFile.po 

You can view more information about these commands by typing:

man msgcat man msgfmt 

Mac OS X

You can get msgcat/msgfmt (as above) either with Xcode or with brew install gettext.

However, it will not add them to your path to avoid conflict with OS X's own gettext utility (says homebrew). You can either add it anyway by adding this to your bash_profile:

export PATH=${PATH}:/usr/local/opt/gettext/bin 

Or otherwise if you only need msgcat/msgfmt you can use aliases. Just add these lines to your bash_profile:

msgcat='/usr/local/opt/gettext/bin/msgcat' msgfmt='/usr/local/opt/gettext/bin/msgfmt' 

Hope this helps! (Thanks to Georgi Stoyanov!)

Windows

On windows you can install MinGW (Minimal GNU for Windows) you need to select mingw32-gettext (bin and dev) durring installation and msgfmt and msgcat exe files will be installed. By default in c:\MinGW\bin. In order to use this tools you need to add that directory to your PATH variable. You can do that from command line using:

set PATH=%PATH%;c:\MinGW\bin 

or from Control Panel > System and Security > System > Advanced System Settings > Environment Variables.

like image 125
Ionică Bizău Avatar answered Sep 29 '22 10:09

Ionică Bizău