Trying to localize a Underscores starter theme [duplicate]

Please note how the translation works: The Text Domain should be same in all the places of your theme. On this page you can see the Theme’s text domain setup: load_theme_textdomain( ‘_s’, get_template_directory() . ‘/languages’ ); And on this page (and many in this theme), you can see the implementation of the Text Domain: _e( … Read more

WordPress Translations

.po and .mo files are for translating strings in code files. For translating post content use a translation plugin. I’ve used a few and find WPML to be the best in many aspects. Incidentally, they have a built-in workflow for translating both content and strings in code files.

How to add a translatable string to post date

You should use placeholders: $time = sprintf( ‘<i class=”fa fa-clock-o” aria-hidden=”true”></i> %s: <time datetime=”%s”>%s</time>’, esc_html__(‘Posted on’, ‘textdomain’), get_the_time(‘Y-m-d’), get_the_time(‘j F Y’) );

How do you translate comments_number function text in a theme?

You have to make these strings translatable by using __() function: comments_number( __(‘Comments (0)’), __(‘Comments (1)’), __(‘Comments (%)’) ); If you want to use the custom textdomain, e.g. ‘test’: comments_number( __(‘Comments (0)’, ‘test’), __(‘Comments (1)’, ‘test’), __(‘Comments (%)’, ‘test’) ); For more information see: __() Theme internationalization Very good article by Samuel Wood a.k.a. Otto: … Read more

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

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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)