Home›Support›English Support›[Resolved] Navigation Translations not showing properly - Transperfect/GlobalLink/Translation.com
[Resolved] Navigation Translations not showing properly - Transperfect/GlobalLink/Translation.com
This thread is resolved. Here is a description of the problem and solution.
Problem:
You are experiencing issues with the Header and Footer not translating correctly on your production site when using Transperfect/GlobalLink/Translation.com. The elements are showing incorrect language tags and the translations are not appearing as expected.
Solution:
We discovered that all the templates, patterns, blocks, and template part translations were set as drafts, which caused the translation errors. To resolve this, you can use the following custom code snippet to publish all these draft items:
function publish_all_custom_post_types() {
$post_types = ['wp_block', 'wp_template', 'wp_template_part', 'wp_navigation']; // List of post types to update
foreach ($post_types as $post_type) {
$args = array(
'post_type' => $post_type,
'post_status' => 'draft',
'posts_per_page' => -1, // Get all drafts
);
$draft_posts = get_posts($args);
if (!empty($draft_posts)) {
foreach ($draft_posts as $post) {
wp_update_post(array(
'ID' => $post->ID,
'post_status' => 'publish',
));
}
}
}
}
// Run the function automatically in the admin area
add_action('init', function() {
if (is_admin() && current_user_can('manage_options')) {
publish_all_custom_post_types();
}
});
We recommend using this code once and then removing it. Please ensure to perform this operation after taking a full backup of your site.
If this solution does not resolve your issue or seems irrelevant due to being outdated or not applicable to your specific case, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If further assistance is needed, please open a new support ticket 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’m working with Transperfect/GlobalLink/Translation.com to update the website translations. I moved to Prod after testing on Dev, but the Header and Footer (including navigation, patterns, etc.) aren’t translating correctly on Prod. I am only translating from English to Dutch on one page and one post so far. They’re showing up like this: nu003cspan class=u0022wpml-ls-nativeu0022 lang=u0022enu0022u003eEnglishu003c/spanu003e nu003cspan class=u0022wpml-ls-nativeu0022 lang=u0022pt-bru0022u003ePortuguêsu003c/spanu003e
Symptoms:
The Header and Footer (including navigation, patterns, etc.) aren’t translating correctly on Prod.
Note: The first three rows of the screenshot shows blank in the columns with Transperfect and the Action.
Questions:
Any suggestions on how to get the navigation to translate properly?
The website copy site was completed successfully, but it looks like the language switcher is not in the navigation menu. Did you already make changes, or did the site not copy completely? What information do you need from me?
I’ve conducted multiple tests but haven’t been able to identify the conflicting template or pattern causing the issue. The pages are using the "page" template, while the page template translations rely on a header pattern that contains the incorrect switcher. However, even after adjusting the translation, the layout still doesn’t function as expected as reusable blocks is not shown.
To investigate further, I’d like to perform a more in-depth review. Could you please provide a backup of your site's wp-content folder along with the database? This will allow me to replicate your site on my local environment and carry out detailed debugging.
You can zip those files and share the links with me using some file sharing platform, I have enabled the private reply for you.
As mentioned earlier, I’ve tried several approaches in the staging environment but haven’t been successful. Without backups to debug locally, resolving the issue will be quite challenging and time-consuming. I hope you understand.
I recommend deleting the current staging site and setting up a new one so I can retest the issue. Additionally, please note that we might need to recreate the staging environment again for further testing in the future.
Upon further debugging I found out that all the templates, pattern, blocks, template part translations was set as draft resulting in the error.
To fix this, I used this custom snippets
function publish_all_custom_post_types() {
$post_types = ['wp_block', 'wp_template', 'wp_template_part', 'wp_navigation']; // List of post types to update
foreach ($post_types as $post_type) {
$args = array(
'post_type' => $post_type,
'post_status' => 'draft',
'posts_per_page' => -1, // Get all drafts
);
$draft_posts = get_posts($args);
if (!empty($draft_posts)) {
foreach ($draft_posts as $post) {
wp_update_post(array(
'ID' => $post->ID,
'post_status' => 'publish',
));
}
}
}
}
// Run the function automatically in the admin area
add_action('init', function() {
if (is_admin() && current_user_can('manage_options')) {
publish_all_custom_post_types();
}
});
I suggest you to use the code once and remove it, also, try this after a backup and let me know if this helps.