po as a template similarly you would use. pot but it contains also translations for a certain language. It’s an optional file and you can create new po/mo files withouth but it’s really nice to have if you’re building your own starter theme/plugin boilerplate or if you’re going to release your theme/plugin publicly.
pot is a template that doesn’t have any translations and it’s used as a template for new translations. POT/PO/MO files are documented really well here, but as a quick refresher: $myText = _( 'My text string', 'my-plugin' ) Įasy enough? Now your theme/plugin is ready to be translated.
Then add this into your theme functions.php: Only useful if the translations are located in a separate language folder because it defaults to the base folder the plugin is located in.”Īnd: “The Domain Path header can be omitted if the plugin is in the official WordPress Plugin Directory.” Or to the top of your main plugin file like this:
#POEDIT TUTORIAL WORDPRESS FREE#
In this article I’m going give you an overview on my theme/plugin localization process with Poedit, which is a free translations editor for po/mo files. Wrapping text strings with _(), _e() and other functions makes a tiny overhead compared to using plain text strings, but you’re going to thank yourself for using them the day your client asks you to make their website multilingual. Making your theme or plugin translateable doesn’t usually take too much of an extra effort, so I usually recommend to make the theme/plugin translation ready right from the start even if you don’t currently plan on translating it.
However you might still want to read through “I18n for WordPress Developers” on WordPress Codex, “Localization” on Theme Handbook and “Localization” on Plugin Handbook to understand how localization works under the hood. I tried to write this article in a way that it contains all the necessary information you might need to make your themes and plugins translation ready.