The problem I was encountering was a result of not realizing that the 3rd parameter for load_plugin_textdomain
should be a relative path to the language directory from WP_PLUGIN_DIR
. Since plugin_dir_path
returns an absolute path, things broke.
Changing the hooked function as follows solved the problem:
add_action('plugins_loaded', array('PluginName', 'loadTextDomain'));
class PluginName {
public static function loadTextDomain() {
load_plugin_textdomain('plugin-domain', false, dirname(plugin_basename(__FILE__ )) . '/languages/');
}
}
Related Posts:
- How to make a WordPress plugin translation ready?
- How to provide translations for a WordPress TinyMCE plugin?
- Preparing a string in an array for localization
- Shortcodes, output buffering, and WordPress functions
- Problems with localization
- Multiple textdomains
- How to properly load text domain of custom mu plugin
- `wp_set_script_translations` with `wp.i18n` does not return translated strings in simple plugin
- WordPress Localization and Templating
- How to properly load text domain of custom mu plugin
- Can’t we use strings defined as PHP constants if we want to translate them in a plugin?
- How to update the language used by wordpress from a plugin
- WordPress: After Gutenberg plugin migration to block.json the localization/ translations with PolyGlot in JavaScript does not work anymore
- Singular name Plugin localization
- How to i18n text coming from the db or from an external source
- Should I always prefer esc_attr_e & esc_html_e instead of _e?
- Some strings from a .mo file do not load
- Should shorcodes in i18n plugins be translated and if so, how?
- A better way to include localized labels in WordPress plugins
- How to render a time-of-day string like ’16:42′ with a site’s chosen time format?
- Frontend language per user
- Generate JSON files for language translation from po file without wp-cli i18n make-json
- Shortcode returning localized HTML part
- load_plugin_textdomain doestn’t work with add_action plugins_loaded
- How to prevent someone from entering strings without making it available for translation?
- Mixing l18n string from my plugin with WordPress’ translations
- Plugin language always shows WP site language, not profile language
- Is hint for translator compulsory while internationalizing a string containing variables?
- Do I lose translations when I change my Text domain for my plugin on wp.org?
- Transform internationalized plugin into internationalized mu-plugin?
- Translation not working for Constant strings in Plugin
- How are themes and plugins localized using the gettext GNU framework?
- Save translation file of third party plugin in a custom plugin?
- React Plugin Settings Page Localization
- How to get locale within WP REST Request?
- How do I create a custom role capability?
- What is the advantage of using wp_mail?
- Export data as CSV in back end with proper HTTP headers
- Calling the widget id of a mult-instance widget from inside the widget?
- Do I need to call do_action in my plugin?
- WooCommerce get Shipping Class of product from either the product id or the order after order is completed
- Dequeue script, but still use wp_localize_script to pass vars
- I can’t find where a hook is being defined in a plugin – Easy Digital Downloads
- Can I add pages to my custom menu via script?
- Replacing WordPress menu functionality with a plugin
- Programmatically Selecting Theme Based on URL
- Why is print_r returning $classObj->userObj in several places on site
- Is it possible to load plugin from console with core ?
- Plugin development: is adding empty index.php files necessary?
- Plugin base URL
- Database for development
- Customize multisite site creation with user data
- Adding plugin settings link upon activation
- How to create multiple Gutenberg blocks in one plugin
- How to disable reCaptcha v3 except on Contact Form 7 pages?
- Plugin translation not working apart from name and description
- Fetching the value of forms in WordPress AJAX
- Buddypress function and global $bp question
- Custom plugin: Loop through taxonomy types and update columns for all types?
- How to add setting section in custom post type [closed]
- Get Current Menu Location inside Nav_Walker
- How to Display my HTML form in my Custom Plugin?
- Where to add hooks in a class
- Insert terms for custom taxonomy on plugin activation, or each page load (init hook)
- Custom GET Parameters In Plugin’s Admin Page
- Adding option to Gallery shortcode
- WordPress Search filter to remove possible script injections
- Incorporate small angular feature in my wordpress site
- Bootstrap doesn’t work on admin menu page-How to override wp-admin style?
- Use just a shortcode from another page
- WordPress class, using add_action to call member function does not work
- random code at the end of file after plugin upload
- How Can I add Fields in wp-option table?
- Where do I put my add_action(… and add_filter(… and do I need to remove them?
- ajax recursive calls on wordpress returning answers outsite the function scope
- Why in this archive page that call query_posts() function show only the last 10 posts?
- WordPress plugin development OOP style
- Let plugin check if taxonomy is already registered by another plugin
- Working of foreach loop with array
- Submit form to a different PHP file in the same plugin folder
- What might be the reason of Couldn’t fetch mysqli_result on another domain?
- $wpdb->update Issue
- wp_insert_post generated mixed permalinks
- Adjust query on single
- Is there any way to pass messages from a script to a redirect target in a hidden fashion?
- What should I pass for $needed_dirs when calling _unzip_file_pclzip (aka PclZip)?
- Custom Path for a Plugin
- Trigger function on Remove block or add new block in Gutenberg JavaScript
- How the add_action is included in the plugin development
- Fatal error: Uncaught Error: Using $this when not in object context
- do I need to sanitize a shortcode’s function input?
- Email content as comment
- Warning: Illegal string offset – on homepage
- Organising and completing posts (mark as read and hide)
- When using an options array the Settings API isn’t creating the database record
- Displaying External Data – Not Posts
- the correct way to use options from settings page [closed]
- I want to add post meta for picture thum during submit for revision
- How to synchronize an e-commerce site and a pharmacy management software?
- woocommerce features to add product along with link