Internationalization
-
Hi,
I really need help with translating a plugin I’ve been developing for a few years. The translation works for some elements but not for others, which is driving me crazy. Initially, I thought the issue was with Gutenberg blocks, but I realized other elements aren’t being translated either.
I’ve tried many solutions all the day… Finally integrated the translation into my main class, instantiated on the plugin’s main page.
namespace myplugin; use Exception; new Core(); class Core { [...] public function __construct(){ // Translation add_action('init', array($this, 'localization')); } public function localization() { load_plugin_textdomain('myplugin', false, plugin_basename(self::getPath('languages'))); } }
The translation is loaded as the major part of the plugin is correctly translated.
When I use standard ‘echo’ statements, it generally works fine:
<p><?php echo __( "The integration of the icons is then done through a shortcode.", 'myplugin'); ?></p>
But I have a class, for example, where the translation doesn’t works:
namespace myplugin; class ZipPack { [...] static public function upload() { try { [...] // Check if a file was uploaded if (empty($_FILES['myplugin-zip']['name'])) { throw new \Exception( __("Please select a .zip file!", "myplugin")); } } } }
I can’t translate this Exception… I’ve even tried:
// Check if a file was uploaded if (empty($_FILES['myplugin-zip']['name'])) { _e("Please select a .zip file!", "managerforicomoon"); throw new \Exception( __("Please select a .zip file!", "myplugin")); }
Thank you for your help.
- The topic ‘Internationalization’ is closed to new replies.