We’ve also tested the Media Title field which behaves similar to the Caption and Description. All translation strings are lost when switching between the active languages configured.
Thanks for reporting this issue, the media translation feature was actually bugged. I just fixed it in the development version. Please download this version and replace it in your plugins folder: https://downloads.wordpress.org/plugin/sublanguage.zip. Tell me if it works better.
Hello maxime,
Thanks for your quick reply. I’ve tested the version you submitted (v.2.4) but the behaviour is the same as previous. This occurs in Media Title, Caption and Description. The translated strings are lost once you switch between configured languages in the system.
Best regards,
Luis
You’re right it was still bugged. Please use this new version with new fixes: https://downloads.wordpress.org/plugin/sublanguage.zip.
Maxime,
I’ve tryed with the new file (also version 2.4), but with no luck. The behaviour is still the same for Title, Caption and Description. Since I can’t tell any difference between the earlier v.2.4 and this one, I wonder if the server @wordpress.org has some kind of cache (if the file downloaded is the intended / new one).
Best wishes,
Luis
Yes maybe… can you try again? Or download from github: https://github.com/maximeschoeni/sublanguage
Hello Maxime,
I’ve tried again, this time using the ZIP downloaded from github. Still no solution for the bug. The behaviour is still the same. Let me know if I can be of some assistance.
Best luck,
Luis
Oh right, there is still a bug. It happens when you’re editing an image with the old interface (mode list in the media tab). Is it what you’re using? I’ll try to fix it.
But if you go in the media tab and select “grid” mode, or if you open a post for editing and click “Add Media” button and browse the media library, it should work fine now.
Ok, I made a new commit, if you want to try again: https://downloads.wordpress.org/plugin/sublanguage.zip
Thanks for your patience!
Hello Maxime,
I run new tests using the release you published. Now, everything seems to be perfect. You now can translate correctly Title, Caption and Description. And you can even do this in Grid Mode (I had noticed what you mentioned about being able to use Sublanguage in List Mode).
Thanks for your precious help. We love Sublanguage. It’s the most intuitive translation plugin, by far.
Best regards,
Luis
Great! Thanks for reporting these bugs!
Maxime,
Sorry for the inconvenience. I’m trying to get the translated strings on the front-end. I’m using this code:
$image = get_post(get_post_thumbnail_id());
echo $image->post_title;
echo $image->post_excerpt;
echo $image->post_caption;
On the front-end I’m always getting the base language (in my case Portuguese), even when the selected language is otherwise English / EN.
Am I extracting the translated strings correctly? Should I be using a specific function from the sublanguage plugin to get the translated strings?
Best regards,
Luis
Posts (or images) queried by get_post() will not be automatically translated. You have to do it manually by using the sublanguage filter sublanguage_translate_post_field:
$image = get_post(get_post_thumbnail_id());
echo apply_filters('sublanguage_translate_post_field', $image->post_title, $image, 'post_title');
echo apply_filters('sublanguage_translate_post_field', $image->post_excerpt, $image, 'post_excerpt');
echo apply_filters('sublanguage_translate_post_field', $image->post_content, $image, 'post_content');
Perfect. Worked like a charm. Thank you so much for the quick answer.
Best wishes,
Luis