Use WordPress default text domain for translating labels

I am wondering if there is a way to use the “default” text domain (“WordPress” or “default”) to translate labels. E.g I have following code: // Register Custom Taxonomy function custom_taxonomy() { $labels = array( ‘name’ => _x( ‘Press category’, ‘Taxonomy General Name’, ‘my_text_domain’ ), ‘singular_name’ => _x( ‘Press category’, ‘Taxonomy Singular Name’, ‘my_text_domain’ ), … Read more

How to get menu strings, categories and tags into po file for translation

I’m prepping my theme for translation. I’ve added the following line to my functions.php, and added the text domain within my theme files. <?php /*** LOAD THEME TEXTDOMAIN ***/ load_theme_textdomain( ‘mytheme’, get_template_directory() . ‘/languages’ ); $locale = get_locale(); $locale_file = get_template_directory() . “/languages/$locale.php”; if ( is_readable( $locale_file ) ) { require_once( $locale_file ); } ?> … Read more

How to reload wordpress textdomains at runtime

I’m currently using this to reload my theme and plugin textdomain in order to send e-mails (admin move, in admin language) in the user language. add_filter(“theme_locale”, array($this, “theme_locale”), 9999, 2); add_filter(“plugin_locale”, array($this, “plugin_locale”), 9999, 2); $this->load_textdomains(); remove_filter(“theme_locale”, array($this, “theme_locale”), 9999, 2); remove_filter(“plugin_locale”, array($this, “plugin_locale”), 9999, 2); public function load_textdomains() { if (function_exists(“WC”)) { WC()->load_plugin_textdomain(); } … Read more

Problem in Internationalizing a plugin built for network level usage

Context: I have created a plugin that is enabled only at the network level and it handles certain synchronizations between the child sites. As it is a network level plugin, it has its menu added to the network dashboard instead of the admin dashboards of child sites. Problem: I have implemented internationalization in the plugin … Read more

load_child_theme_textdomain doesn’t work in function.php

I have a child theme which is not localized. So I added this in function.php add_action( ‘after_setup_theme’, ‘my_child_theme_setup’ ); function my_child_theme_setup() { load_child_theme_textdomain( ‘mytheme’, get_stylesheet_directory() . ‘/languages’ ); } It doesn’t work. I searched for hours and I read somebody advised putting this to the top of header.php load_child_theme_textdomain( ‘mytheme’, get_stylesheet_directory() . ‘/languages’ ); Suddenly … Read more

Theme check: Missing a text-domain

I’m using following code to display the number of comments: printf(_n(‘1 comment’, ‘%1$s comments’, get_comments_number()), number_format_i18n( get_comments_number() ), ‘text-domain’ ); Is there something wrong with it? The theme check plugin is giving the warning : WARNING: Found a translation function that is missing a text-domain. Function _n, with the arguments ‘1 comment’,’%1$s comments’ I do … Read more

Multiple text-domains per single plugin – admin and frontend

There is a plugin: In admin area it has about 300 various strings added via __(”, ‘my-textdomain’). Most of these are form labels, titles, etc. On “frontend” (which end user sees), there just 15 strings added via the same __(”, ‘my-textdomain’) method Most website editors will want to translate “frontend” part. Admin area part is … Read more

How to override languages files in wp-content/languages/themes with child theme

I want to create a child theme for TwentyFifteen theme, which will customize a lot of things, including translation. When I install WordPress in my language (Farsi), it includes TwentyFifteen language files in wp-content/languages/themes So when I create a languages folder in my child theme and add customized language files to it and add load_theme_textdomain( … Read more

How can I translate the name of my Plugin for other languages?

How can I translate the name of plugin for other languages? For example: When WordPress is in pt-BR language, the plugin would be “Meu plugin”. If the WordPress is in en-XX language, the plugin name would be “My plugin”. Thanks! 1 Answer 1 After searching a little bit more, I found that in the generation … Read more

Theme elements not translating

Ive got a theme that is set-up for translating but didn’t come with any translations. I used poedit to automatically detect the strings, and subsequently translated it in full. However certain elements aren’t translating in admin or on the site. I can see in poedit that Ive translated all the strings including those that aren’t … Read more