Unable to find translations in WordPress theme

There are three usual possibilities: Translation files somewhere in theme’s directory. Translation files in site’s directory, defined by WP_LANG_DIR constant (typically wp-content/languages). Theme’s original strings are in different language, so that is its default state and it needs to be translated to English.

How to translate functions.php?

Added to the functions.php the next: $pather = get_stylesheet_directory().’/languages’; load_child_theme_textdomain( ‘Savia-child’, $pather ); And then called it as: __( ‘text to translate’, ‘Savia-child’); In the child theme I have created a dir: /languages and put there po and mo files with the names: [locale].po/.mp like: ru_RU.po and ru_RU.mo. That is.

POEDIT – Continue with translations

You can edit .po files in text editor. Structure is very simple (some header, do not touch it) and a number of translations like that: #: 404.php:21 msgid “Sorry! Page Not Found !” msgstr “” You can ignore comments started with #. msgid – string how it appears in php code msgstr – translation (if … Read more

/languages/ folder missing in default themes

Themes and plugins on wordpress.org don’t need a /language folder anymore. The translation is made via Glotpress on https://translate.wordpress.org/. Glotpress parses the files and you can start to translate. The translated .mo and .po files get automatic updates, if a translation string changes. They are stored in /wp-content/languages If you don’t host your Theme or … Read more

Translate plugin admin interface

Excerpts from Plugin Handbook The text domain must match the slug of the plugin. If your plugin is a single file called my-plugin.php or it is contained in a folder called my-plugin the domain name should be my-plugin. If your plugin is hosted on wordpress.org it must be the slug of your plugin URL (wordpress.org/plugins/). … Read more

Can I set WordPress to display languages based on system language without a plugin?

PHP can read the ‘HTTP_ACCEPT_LANGUAGE’ header from the browser request, but this might not be easy to parse if there is more than one accepted language set. For the simplest case, when one language is set as accepted, you need to read only first 2 characters from this header: $language = substr($_SERVER[‘HTTP_ACCEPT_LANGUAGE’], 0, 2); But, … Read more