Internationalization Internationalization is the process of developing your theme in such a way that its custom text can be translated into other languages. The term is often abbreviated as “i18n” because there are 18 letters between the “i” and “n,” the first and last letters. In this article, you will learn how to internationalize your WordPress themes and why it is important. Why internationalization is important WordPress is used all over the world, in countries where your native language is not used. The strings in the WordPress themes need to be coded in a special way so that they can be easily translated into other languages. Even if you yourself do not know multiple languages, internationalization leaves the door open for translators to localize the text. Localization is the process of taking internationalized text and translating it for a specific language and locale. It is often abbreviated as “l10n.” WordPress has a built-in translation system that allows localizing a theme without having to modify the source code of the theme itself. This is important because it means that users can keep up with theme updates while using their preferred translation. You can certainly build a WordPress theme without internationalization, particularly if it’s for a site that you know will never be translated. But in most cases, it is considered standard practice to internationalize all of your theme’s text. For one, it means that it can be used by people in other languages, giving you a wider audience. And it is also a requirement when submitting a theme to the official Theme Directory. How to internationalize your theme Getting your text domain The text domain is a unique identifier, allowing WordPress to distinguish between all of the loaded translations. That means that you need something unique for your theme so that WordPress will recognize translations that belong to it. The text domain is used in three different places in your theme: In the style.css file header. As an argument in internationalization functions. As an argument when loading translations (optional for themes submitted to the WordPress Theme Directory). Your theme’s text domain should always match your theme slug, as described in the Reading this handbook documentation. This is a central component in making sure your theme is ready for translation. The de facto standard (and requirement if submitting your theme to the WordPress Theme Directory) is to use the kebab-case version of your theme name. This means that it should: Use all lowercase letters. Have no spaces. Hyphenate when there are multiple words. So if your theme’s name is Fabled Sunset, your text domain should be fabled-sunset. Defining your text domain As described in the Main Stylesheet documentation, you can configure several important pieces of metadata about your theme via the style.css file header. In particular, there are two meta values you can define related to internationalization: Text Domain: The string used for the text domain for translations. Domain Path: A relative path to where theme translations are stored. WordPress uses this field when the theme is disabled to detect translations. Defaults to /languages if not defined. For translations to work correctly, you must at least define the Text Domain field, which should be your theme’s slug. Let’s imagine your theme name is “Fabled Sunset” and you want translations stored in your theme’s /assets/lang folder. Your theme’s style.css should define these fields like so: /** * Theme Name: Fabled Sunset * ... * Text Domain: fabled-sunset * Domain Path: /assets/lang * ... */ It’s important to add this metadata to your style.css file because WordPress uses it even when the theme is not enabled (for example, when viewing all themes from the Appearance > Themes screen in the admin). Wrapping text with internationalization functions For text in your theme to be easily translated in your theme, it must be wrapped in an internationalization function instead of hardcoded. The available internationalization functions are listed in the Common APIs handbook. In a typical HTML-based webpage, you would add plain text strings. For example, take a look at this example heading: