I am currently facing an issue with translations in my plugin that only appeared after the update to WordPress 6.7. Before this update, everything was working perfectly.
Despite verifying that my text domain is consistent throughout my code and ensuring that my translation files (e.g., my-plugin-fr_FR.mo
) are correctly placed in the /languages
folder within my plugin directory, the translations are not being loaded properly.
I am still using the load_plugin_textdomain()
function to load my translations, even though I am aware that this has not been mandatory for a while now, as WordPress should automatically handle the loading of translations for plugins hosted on www.ads-software.com.
I’ve noticed that calling load_textdomain()
manually works, but this approach is not ideal as it loads only one specific language and bypasses WordPress’s automatic language loading mechanism. Additionally, when I check with Query Monitor, it seems that WordPress is searching for translation files in the root of the plugin directory instead of in the /languages
subdirectory.
Has anyone else experienced translation issues after updating to WordPress 6.7? Are there any new requirements or changes in translation handling that I should be aware of?
Thank you in advance for any help or insights you can provide!
]]>System Information:
Server Environment:
Additional Information:
How can I resolve this encoding issue? Is there any specific configuration needed for non-English (Chinese) character support in the PDF generation?
]]>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.
]]>Thank you again for this wonderful and indescribably useful plugin.
Kind regards,
]]>wp i18n make-pot . languages/udemy-plus.pot
I got a bunch of errors, as an example…
'39661-40045' => ['prev' => 39661, 'next' => 40045, 'comments' => [0 => class Peast\Syntax\Token { ... }, 1 => class Peast\Syntax\Token { ... }, 2 => class Peast\Syntax\Token { ... }, 3 => class Peast\Syntax\Token { ... }, 4 => class Peast\Syntax\Token { ... }]],
and..
11.7518 52347560 256. Peast\Syntax\CommentsRegistry->onTokenConsumed($token = class Peast\Syntax\Token {
public $type = 'String'; public $value = '"default"'; public $location = class Peast\Syntax\SourceLocation { public $start = class Peast\Syntax\Position { protected $line = 2979; protected $column = 58; protected $index
= 123953 }; public $end = class Peast\Syntax\Position { protected $line = 2979; protected $column = 67; protected $index = 123962 } } }) phar://C:/laragon/usr/bin/wp-cli/wp-cli.phar/vendor/mck89/peast/lib/Peast/Syntax/EventsEmitter.php:57
Those kind of lines massively, any idea what’s going on?
BTW I know that my code it’s not the problem because I can generate the myDomain.pot file with qsandbox tool online, but would like to know how to configure wp-cli to get the desire result if it’s possible.
]]>I just began translating it into Brazilian Portuguese and will soon begin translating into Colombian Spanish.
Apart from that, I wanted to check if you are interested in collaboration in improving/updating it’s interface. If so, can you point me in the right direction. Is there a repository?
Thanks
]]>With best regards
Mathias