Step 3: Producing the final MO file
We’re now in the final leg of the localization process and only one more step stands between us and a beautifully translated theme or plugin: compilation. This may sound like something reserved for programmers, but in the case of GNU gettext it simply refers to turning the text PO file into a high-speed binary file.
If you are using poEdit then this step will already be finished – that’s quick work! Every time you save the PO file, poEdit will automatically compile and save a MO file too.
If you are using GNU gettext then you will need to issue something similar to this command:
msgfmt -o fr_FR.mo fr_FR.po
Change the output filename
fr_FR.mo and input filename
fr_FR.po according to your situation.
And that’s it! You can now copy this MO file into the theme or plugin directory (taking care about naming conventions for plugins) and test it out. You may discover that some translations are not accurate and you will have to re-edit and re-compile a few times until you are happy.
Remember that when you distribute the localized files please do include both the PO and MO files as this means it is possible for someone else to carry on the translation process in the future.
A translation does not have to be into a different and it is possible to use the methods described in this guide to make your own specialized versions of WordPress and without changing any code. For example, the WordPress administrative dashboard greets users in English with a ‘Howdy’. For a business site you may decide this isn’t appropriate and want to change it to ‘Welcome’. One method would be to search through the WordPress code and change the text itself, but a neater way is to create a special localization. In this example it would be translating from English to English. All text would remain the same apart from the one you wanted to change:
msgid "Howdy %s" msgstr "Welcome %s"
You now have your own personalized version of WordPress!