Skip Navigation

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.

This topic contains 2 replies, has 1 voice.

Last updated by T4ng 4 weeks ago.

Author Posts
March 13, 2025 at 3:09 pm #16812638

T4ng

Background of the issue:
I am working on a site under development and trying to exclude specific block content, such as code and picture/image tags, from XLIFF files. I can provide an XLIFF file for reference, but I believe discussing it live would be more efficient.

Symptoms:
I couldn't find specific documentation on how to exclude block content from XLIFF files.

Questions:
How can I exclude specific block content from XLIFF files?

March 13, 2025 at 3:33 pm #16812698

T4ng

Just found this in the meantime.
https://wpml.org/forums/topic/remove-html-and-shortcodes-from-xliff-export/

This answer is 2 years old. Is it still valid?

As far as I understand, we the ATE can exclude natively tags only content, but WPML doesn't offer any tool to exclude them for an XLIFF export.

Am I right?

For my translator, working with an online translation tool is a no go.

AI tools suggest this kind of solutions:

add_filter('wpml_translate_single_string', 'exclude_html_tags_from_translation', 10, 5);
function exclude_html_tags_from_translation($translation, $original_value, $string_context, $domain, $language_code) {
// Vérifie si la chaîne contient des balises HTML
if (preg_match('/<[^>]+>/i', $original_value)) {
return $original_value; // Retourne la chaîne originale sans traduction
}
return $translation;
}

Would such a piece of code prevent to reimport the content properly?

Or is it something that can be set on the CAT tool?

Thanks

March 14, 2025 at 9:37 am #16815501

Dražen
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hello,

Thanks for contacting us.

While you wait for my colleague to take over the ticket, let me try to help you with the issue quickly.

You mentioned the blocks, so I guess these are custom blocks or if not they would need to have XML rules for WPML to know what part to translate. In that XML file you can set which part of the block is translatable by including it in the XML rule or not.

- https://wpml.org/documentation/support/language-configuration-files/make-custom-gutenberg-blocks-translatable/

Let me know if that helps.

Regards,
Drazen

March 18, 2025 at 6:02 pm #16831968

T4ng

Hi Dražen,

Thanks for your reply.

Indeed, I'm talking about custom blocks.

Actually, our translator's CAT tools seems a bit more evolved than the POedit I tested my file with. His editor seems to exclude / hide the code and image blocks. So that's ont an issue for them to work with pour XLIFF, without further configuration.

Still, I'll remember your advise in case I encounter more difficulties regarding these fields in the future.

Thank you.

Best Regards