Articles of translation

Translations does not work with .pot file

I’ve created a theme at underscores.me and it seems it is multi-language ready. There is a .pot file in the language folder, so I downloaded POEdit and translated the things in there (like Posted on, Edit, 1 Comment, x Comments and so on) Are the above posted words not from the theme but from WordPress? […]

WordPress Translations

I’ve just recently learned about .po and .mo files in WordPress Themes. My question is, are these files supposed to be used to translate page and post content or just the WordPress backend along with Plugins?

Return Value of load_plugin_textdomain

Good Day, I’m trying to translate my plugin but it doesn’t seems to work. I read that I should check the return value of “load_plugin_textdomain” to see if it’s false (meaning it doesn’t find my translation file), but I cannot find how to find this value. Can someone point me in the right direction? Thanks […]

Translating a pager string

Most of WordPress function found in themes look like this: <?php echo get_next_posts_link( ‘Older posts’, $the_query->max_num_pages ); // display older posts link ?> <?php echo get_previous_posts_link( ‘Newer posts’ ); // display newer posts link ?> This works as expected. However, how can I rewrite this in order to translate it? I tried: <?php _e( echo […]

Proper way to use esc_html__ and esc_attr__ etc for escaping value for translation

From the articles on Codex, esc_attr_e is proper way to escaping value for translation. But from other articles, I read about sanitizing issue and security issue for some escaping code. For my code, I am using this: <h4><?php esc_attr_e( ‘PREVIOUS ARTICLE’, ‘myweb’ ); ?></h4> Is my code proper for translation? If no, what the code […]

Translate a child theme with pure PHP and gettext

I’m trying to translate a child theme of a parent theme that has all msgstr empty. Therefore, I’ve created the file de_DE.mo using the “WordPress i18n tools” recommended in the docs together with msgfmt. I put the file into my child theme directory’s subfolder languages/child. To tell WordPress about it, I added this to my […]

How do you translate comments_number function text in a theme?

If I’m just echoing regular text, I do this: <?php _e(‘This post is closed to new comments.’,’my-theme’) ?> But how would I translate the text in comments_number(); so that the “Comments” text can be translated? Like this: <?php comments_number( ‘Comments (0)’, ‘Comments (1)’, ‘Comments (%)’ ); ?>

Update-safe translating of single text string in plugin

I’m trying to change an English text string in a plugin that has the following structure: ├── language │   ├── albdesign-wc-donations-sq.mo │   ├── albdesign-wc-donations-sq.po │   └── default.pot └── woocommerce_donations_on_cart.php I’m using only English on the website I installed the plugin, so I could also just edit the English text strings in woocommerce_donations_on_cart.php, but I would […]

How to add a translatable string to post date

I am trying to add a translatable string, like “posted on:” to my WordPress theme post dates. I have already added a font-awesome icon next to it and I’d like to have the string after the icon. The code for the date is $time = ‘<i class=”fa fa-clock-o” aria-hidden=”true”></i>’ . ‘<time datetime=’ . get_the_time(‘Y-m-d’) . […]

How to get Post title by locale with Qtranslate-X

I need to send 2 emails, when new comment is posted and when new comment is approved. Site is multilingual and uses qtranslate-x plugin. Here is code, which sends email when comment is posted. In this case ‘get_the_title($post->ID)’ returns post title on one language as expected. function kvkoolitus_email_comment_posted( $comment_ID, $comment_approved ) { if( 0 === […]