Internationalization (i18n) and localization (l10n) are important and often overlooked aspects of WordPress development. Themes should give developers and administrators the ability to add translations for users from among the roughly 95% of the world whose first language isn’t English.
There are plenty of articles written about how to provide i18n and l10n for a single theme, but what about child themes? When building a child theme, assuming the parent theme is properly internationalized, developers may want to do any or all of the following:
- Provide localizations that aren’t provided by the parent theme, either in different languages or in gaps in existing localizations.
- Modify existing localizations in the parent theme, for instance if the developer of the child theme wants to change the wording of some area of the site.
- Provide new internationalizations unique to the child theme, using the child theme’s text domain.
Let’s start by looking at a simple example of i18n in a WordPress theme. For the purposes of this article, the parent theme will be called “Parent Theme” with the text domain parenttheme
, and the child theme will be called “Child Theme” with the text domain childtheme
.