To implement the multi language WordPress translation using __() in an external PHP file of a plugin, follow these steps:
Here's an example code snippet:
// Load the text domain for the current language
load_plugin_textdomain( 'your-plugin-textdomain', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
// Use the __() function to translate your strings
echo __( 'Hello world!', 'your-plugin-textdomain' );
This will translate the string 'Hello world!' into the user's current language, using the translation files located in the 'languages' folder of your plugin.
Asked: 2022-05-06 11:00:00 +0000
Seen: 9 times
Last updated: Dec 31 '21