If discussed plugin already uses load_plugin_textdomain()
function to load its translations, usually it is enough to place <plugin_name>-<locale_code>.mo
file to the wp-content/languages/plugins
directory. If it doesn’t (or you can’t do it for some reason), you can use init
hook to load its translation via your functions.php
. Here is an example from one of my child themes:
function load_plugin_translations() {
if ( is_plugin_active( 'woocommerce-payment-status/woocommerce-payment-status.php' ) ) {
load_textdomain( 'woocommerce_payment_status', get_stylesheet_directory() . '/languages/woocommerce_payment_status-' . get_user_locale() . '.mo' );
}
}
add_action( 'init', 'load_plugin_translations' );
Here I use woocommerce_payment_status-<locale>.mo
translation file from the languages
folder under my child theme. Replace woocommerce-payment-status/woocommerce-payment-status.php
plugin ID and woocommerce_payment_status
textdomain ID according to your plugin.