Create .po templates for WP themes via Poedit
Creating a .po template can be tricky using Poedit, but here are the exact steps that work for me.
Micro Tut!
To create a new template.po
and template.mo
files for your theme, ensure the theme is internationalized, and follow these steps:
- In your theme, create a directory called
/languages/
- Open Poedit and visit Preferences; set to “Automatically compile .mo file on save”
- Go to File > New Catalog and fill in the fields as follows (modify values as needed):
Translation properties
- Project name and version: WordPress Example Theme 2.0
- Team: Example Team
- Team’s email address: team@example.com
- Language: English
- Charset: UTF-8
- Source code charset: UTF-8
- Plural Forms: nplurals=2; plural=(n != 1)
Sources paths
- Base path: .
- Paths: ..
Sources keywords
__
_e
_n
_x
- (and any others used in the theme)
After configuring the new poedit catalog, click “OK”, and then “Save as..” /languages/template.po
(a .mo
will be created automatically).
At this point, you’ll see “Source text” listed along with some other blank fields (Translation, Notes, et al). We’re just creating the template files, so nothing further needs done with translating all the strings or whatever.
To complete the process, click the “Update” button (click “OK” for “Update summary” popup). Then finally, “Save” again to make it all happen and then “Quit” and check your two new files. If all went well, your theme will now have a working template.po
and template.mo
ready to go for localization.