How can I create an .mo file for Wordpress
Asked Answered
C

4

35

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

How can i do this?

Coulson answered 21/12, 2010 at 13:15 Comment(0)
I
58

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.

Immunogenic answered 2/8, 2013 at 14:19 Comment(9)
No 'msgcat' or 'msgfmt' on Mac OS X Mavericks. Couldn't find it in brew search either. What OS/Terminal am I supposed to run that from ?Charlatanry
@Norris I am a Linux user. I don't have a Mac to be able to test it, but this will help you.Manuel
Author of the "Msgcat and Mac OS X" post here. To clarify, my post was about using the Tcl package msgcat, not installing the command line tools discussed here, so it might not be much help.Nihi
I was just upset because the answer threw me of when I discovered that it's a Linux specific command. Now that the answer mentions it I'm all right :)Charlatanry
If someone has a solution for Mac OS X/Windows is free to edit the answer or to leave a comment here.Manuel
I have msgcat/msgfmt on my OS X installation. I think it was bundled with XCode.Hysterogenic
Wow. This was easier! I had the same issue too! :DLiguria
If you're on OS X you can get msgcat/msgfmt 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 export PATH=${PATH}:/usr/local/opt/gettext/bin to your bash_profile or else if you only need msgcat/msgfmt anyway you can use alias — add msgcat='/usr/local/opt/gettext/bin/msgcat' and alias msgfmt='/usr/local/opt/gettext/bin/msgfmt' to your bash_profile. Hope this helps!Daggna
on Windows you can install gettext-devel package in cygwinVilla
B
6

If you have opened POedit, then select language in which to translate and click on ok, then it fetch all the items/strings where __ or _e functions were applied to be translated. Just translate them and do these steps like go to catalog select update from sources and then save current catalog. MO file generated/updated successfully.

Regards, Zubair Khan

Belayneh answered 28/7, 2011 at 9:43 Comment(0)
L
4

Generally, you could run the .po file through a tool like pocompile. Some editors are a bit more comfortable, for example, Poedit can compile .mo files automatically. :)

Lengthwise answered 21/12, 2010 at 13:21 Comment(1)
Thanks. I have opened poedit but i dont know how it generates me the .mo files. can you giv eme some tipps?Coulson
D
2

See http://codex.wordpress.org/WordPress_Localization WordPress in Your Language « WordPress Codex and http://codex.wordpress.org/Files_For_Direct_Translation Files For Direct Translation « WordPress Codex and http://codex.wordpress.org/I18n_for_WordPress_Developers I18n for WordPress Developers « WordPress Codex

Dannydannye answered 21/12, 2010 at 15:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.