.po and .mo files
The three file types
.pot |
The template. A list of every translatable string, no translations. Ships with the theme |
.po |
Your translation, human-readable. What you edit |
.mo |
The compiled version. What WordPress actually reads |
The theme’s template is at wp-content/themes/rural-blog/languages/rural-blog.pot.
With Poedit
- Download Poedit (free; poedit.net).
- File → New from POT/PO file, choose
rural-blog.pot. - Pick your language when asked.
- Translate. The list shows each source string; type the translation underneath.
- File → Save as, named for your locale —
de_DE.po. Poedit writes the matchingde_DE.mobeside it automatically.
Find your locale code in the WordPress translate.wordpress.org locale list, or
just read it off Settings → General → Site Language — it is what appears in
the WPLANG option.
Where to put the files
Not in the theme folder. Files there are deleted by the next theme update.
Put them in WordPress’s own language directory:
wp-content/languages/themes/rural-blog-de_DE.mo
wp-content/languages/themes/rural-blog-de_DE.po
Note the naming: rural-blog- + locale, with the theme’s text domain as the
prefix. That folder survives updates of WordPress, the theme and everything else.
Placeholders
Some strings contain %s, %d or %1$s. They are replaced at runtime with a
name, a number or a link.
- Keep them. A string that loses its placeholder loses the value that was going into it.
- Numbered placeholders (
%1$s,%2$s) can be reordered if your language needs a different word order. Unnumbered ones cannot. - Some strings have singular and plural forms; Poedit shows a tab for each form your language uses.
Context and comments
Strings with a translator comment — Poedit shows them in the sidebar — carry
information you need. /* translators: %s: Author name. */ tells you what is going
into the placeholder.
A few strings have a context (they appear twice with different meanings, like Password as a label and Enter as a button). Poedit keeps them separate; treat them as separate strings.
Testing
- Set Settings → General → Site Language to your locale.
- Upload the
.motowp-content/languages/themes/. - Reload the front end.
Nothing changed? Check the filename exactly — rural-blog-de_DE.mo, hyphen
between the domain and the locale, underscore inside the locale — and that you
uploaded the .mo, not only the .po.
Sharing it
If you have translated the theme into a language others use, please contribute it at translate.wordpress.org. Everyone in that locale then gets it automatically, with no files at all.