Author and Custom option is not working for Custom Order Numbers Plugin
-
Hi,
I am encountering an issue where translations for my plugin Custom Order Numbers for WooCommerce are not working as expected with Loco Translate when using the “Author” or “Custom” translation location options.
Here’s a brief overview of my setup:
Plugin Text Domain: custom-order-numbers-for-woocommerce
WordPress 6.7
Translation Loading Code as below: Basically this is the patch I have done after the WordPress 6.7 to correct the translation issue where the notice is being displayed for translation loading too early.add_action( 'plugins_loaded', array( &$this, 'con_load_textdomain' ) );
public function con_load_textdomain() {
$domain = 'custom-order-numbers-for-woocommerce';
$locale = apply_filters( 'plugin_locale', get_locale(), $domain );
$loaded = load_textdomain( $domain, trailingslashit( WP_LANG_DIR ) . $domain . '-' . $locale . '.mo' );
if ( $loaded ) {
return $loaded;
} else {
load_plugin_textdomain( $domain, false, __DIR__ . '/langs/' );
}
}Translation Files: .po and .mo files are present in /langs/ and are correctly named.
Issue: When using Loco Translate:
- The translations work with the System location but fail with the Author or Custom options.
- Despite having the correct file structure and permissions, the translations from these locations are not being applied.
Troubleshooting Steps Taken:
- Verified the
.mo
and.po
files are generated correctly. - Checked the locale using
get_locale()
, and it matches the file names. - Tested with the default WordPress theme and no other plugins activated.
- Enabled debugging, but no errors related to translation loading are logged.
Also, checked with the
init
andafter_setup_theme
but it didn’t help.Could this be an issue with how the
load_textdomain
andload_plugin_textdomain
functions are used in my code? Or does Loco Translate require additional adjustments for plugins that load translations manually?You can take this patch copy to check the issue.
Any guidance or insights would be greatly appreciated!
Thank you for your time.
Regards,
Kartik Parmar
- You must be logged in to reply to this topic.