This thread is resolved. Here is a description of the problem and solution.
Problem:
The client was preparing their theme for translation and needed to register hardcoded image alt attributes for translation with WPML. Since the images were hardcoded in the theme (not in the Media Library), they wanted the alt text to be translatable.
Solution:
We explained that any hardcoded string, including image alt tags, must be wrapped in a gettext function (e.g., __() or _e()) with a textdomain to be detected by WPML’s String Translation. For example:
<img src="image.jpg" alt="<?php echo __('My alt text', 'your-text-domain'); ?/>">After making this change, WPML could register the string and the alt text was successfully translated.
For a complete guide on making hardcoded theme and plugin strings translatable—including how AI can simplify the translation workflow—see: Translate WordPress Themes and Plugins with AI.
Please note that this solution might be 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 the issue persists, 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.
This topic contains 1 reply, has 0 voices.
Last updated by 8 months, 3 weeks ago.
Assisted by: Itamar.