This thread is resolved. Here is a description of the problem and solution.
Problem: The client was unable to see the translated string for a custom plugin named 'growytasty' on the frontend, despite having scanned for strings and translated them in WPML. Solution: We discovered that the issue was related to the text domain not being loaded correctly. To resolve this, we added the following code to the 'growytasty.php' file to ensure the text domain is loaded:
After adding this code, the text domain loaded properly, and the translation appeared correctly on the frontend. For more details on configuring and loading translation files, you can visit our documentation: Translating the Theme You Created.
If this solution does not apply to your case, or if it seems outdated, we recommend opening a new support ticket. Also, check related known issues at https://wpml.org/known-issues/, verify the version of the permanent fix, and confirm that you have installed the latest versions of themes and plugins. For further assistance, please visit our support forum at WPML Support Forum.
This is the technical support forum for WPML - the multilingual WordPress plugin.
Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.
Background of the issue:
I am trying to use string translation for a Bespoke/Custom Plugin in WPML. I have added the plugin, specified the text domain, scanned for translatable strings in Theme and String Localization, and translated the strings in String Translation.
Symptoms:
On the frontend, the string was not translated. I have tried deactivating unnecessary plugins and changing the theme, but the issue persists.
Questions:
Why is the string translation not working on the frontend?
Are there any additional steps required for translating strings in a custom plugin?
Can you please also share the code part where that string is added?
Also, can you please let me know if you had the chance to also try to remove all the local/server/CDN caching, too? I can see that you also have a caching plugin active so please try to clear all the caching, too.
Cache isn't the issue since the issue is on my local / dev site as well.
I wrote down the steps i followed on the initial form but it removed it.
1) Go to theme and plugin localizations
2) Find the plugin "growytasty" and scan for strings
3) Once strings found ( 17 were found ) then i translated it ( text domain - growytasty )
I would like to request temporary access (wp-admin and FTP) to your site to test the issue.
(preferably to a test site where the problem has been replicated if possible)
**Before we proceed It is necessary to take FULL BACKUP of your database and your website. Providing us with access, you agree that a backup has been taken **
I often use the Duplicator plugin for this purpose: http://wordpress.org/plugins/duplicator/
You will find the needed fields for this below the comment area when you log in to leave your next reply.
The information you enter is private which means only you and I have access to it.
NOTE: If access to the live site is not possible and the staging site does not exist please provide me with a duplicator package created with the duplicator plugin.
You are not directly outputting the "Producer" string in your code. Instead, you are passing it to WooCommerce via the $tabs['producer']['title'] array entry, and WooCommerce handles rendering it on the product page.
I did a quick test to make sure it is being picked up correctly by adding "test" in front of it, this worked and it displayed in the front end as well as being picked up by String Translation.
So far we know that the string is being picked up in the front end as well as String Translation.
since this string is not being translated properly, the issue is likely related to the text domain not being loaded.
To verify I added this code in growytasy.php and reloaded the front end at the footer.
add_action( 'wp_footer', function() {
// This will output whether the text domain is loaded correctly
if ( is_textdomain_loaded( 'growytasty' ) ) {
echo '<p>Text domain growytasty is loaded.</p>';
} else {
echo '<p>Text domain growytasty is NOT loaded.</p>';
}
});
( I have removed now since after registering the text domain verified that it is being loaded)
The results are that the textdomain is not being loaded properly, which also explains why the .mo/.po files are missing from the plugin.
To load the text domain I added the following code in growytasy.php
function growytasty_load_textdomain() {
// Adjust the path to the 'languages' folder if needed
load_plugin_textdomain( 'growytasty', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
}
add_action( 'plugins_loaded', 'growytasty_load_textdomain' );
The translation is working OK now and the text domain is loaded properly.
Thank you so much for your help.
The issue has been resolved.
Manage Cookie Consent
We use cookies to optimize our website and services. Your consent allows us to process data such as browsing behavior. Not consenting may affect some features.
Functional
Always active
Required for our website to operate and communicate correctly.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
We use these to analyze the statistics of our site. Collected information is completely anonymous.The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
These cookies track your browsing to provide ads relevant to you.