Home › Forums › Pro Support › WPML and "Read more…" translation problems
- This topic has 34 replies, 4 voices, and was last updated 2 years, 4 months ago by
Tom.
-
AuthorPosts
-
October 14, 2020 at 9:14 am #21147
Samuel
ParticipantJust to be clear here is the “workflow” :
– I create a category X in French.
– I translate this category to Spanish, it becomes a category Y in Spanish directly linked to the category X in French.
– I create an hotel page in French to which I apply category X
– I translate this page to spanish and it’s automatically applying the category Y to it.
– I make a WPSP list for the category X.
– I create a french post where I include this WPSP list which is displaying hotel in French.
– I translate this post to spanish and it includes the same WPSP list which is displaying hotel in spanish, except button, but normal because this is the only part that is produced by the plugin itself, everything else is produced by translations I’ve made.October 14, 2020 at 9:49 am #21153October 14, 2020 at 2:01 pm #21175Tom
KeymasterAbsolutely, they can contact us through our form here: https://wpshowposts.com/contact/
October 19, 2020 at 2:49 am #21350Samuel
ParticipantHi @Tom, as you’ll see there WPML is saying that it’s an incompatibility issue with WPSP. So they are ok to work with you, if they don’t contact you directly, they have a page where plugins and themes author normally contact them : https://wpml.org/documentation/theme-compatibility/go-global-program/
Hope you guys will find a solution !October 20, 2020 at 2:11 pm #21430Tom
KeymasterWe haven’t heard from them yet. From their latest reply, it seems they’re still looking into the issue.
October 23, 2020 at 2:23 am #21510Samuel
ParticipantHi Tom, yes they’re working on it, and they say they’ll contact you, hope you’ll find a solution together ! I’m a bit afraid I’ll have to change plugin that is basically everywhere in my website…
October 25, 2020 at 3:13 am #21607Samuel
ParticipantHi @Tom, I had a reply from WPML Support and it’s not good. Basically their solution is : create a new WPSP list for Spanish posts and insert it manually… obviously this will work, I’ll can translate read more button because it’s a new list… but I mean, this is not what I’m looking for… I have and I’ll have hundreds of WPSP lists, this is an insane solution and “nothing” is not a translation plugin is supposed to do… Here everything is working find, same WPSP list is displaying dynamically posts in spanish perfectly, the only problem is the read more button (because it’s the only “non dynamic” item is this workflow).
Did they contact you to see how to solve this ? If not, could you contact them ? (here : https://wpml.org/documentation/theme-compatibility/go-global-program/)
October 26, 2020 at 2:23 pm #21655Tom
KeymasterPerhaps something like this would work?:
add_filter( 'get_post_metadata', function( $output, $object_id, $meta_key ) { if ( 'wpsp_read_more_text' === $meta_key ) { if ( 'en_US' === get_locale() ) { return 'English text'; } if ( 'es_ES' === get_locale() ) { return 'Spanish text'; } } return $output; }, 10, 3 );
October 27, 2020 at 1:47 am #21713Samuel
ParticipantHi Tom,
Thanks, but this function is breaking everything.
But yes, as an alternative to solve this, I like the idea to force what text would be inside the read more button as I’m only using the button option for this purpose.
I tried replacing the
en_US
withfr_FR
but it didn’t work either.October 27, 2020 at 2:25 am #21717Gary
ParticipantI actually think this has got something to do with WPML’s Advanced Translation Editor (ATE).
Using the code that Tom provided earlier in this thread (not the latest one though; that broke my website), I was able to get the ‘read more text’ field into ATE. I was also able to translate it. The problem is, the translation doesn’t appear at the frontend. See https://www.screencast.com/t/0f5qEQZR
I have inspected the code, and the English is still there. See https://www.screencast.com/t/Y2Pe8bpa
I know there are currently big problems with WPML’s ATE. All the hyperlinks are failing to translate at the moment. They have said it ‘only’ happens when a webpage’s URL has an hyphen or a slash, but for those of us using permalinks, that is almost all our pages/posts. It is an issue that’s been going on for weeks and hasn’t been resolved. Maybe this ‘Read Me’ issue is connected. I have no idea. All I know it that it is very frustrating to a bilingual website at the moment.
October 27, 2020 at 2:11 pm #21755Tom
KeymasterWhen you say it broke everything, what do you mean? What did it break, exactly?
Let me know 🙂
October 27, 2020 at 7:42 pm #21775Gary
ParticipantThe page gets compressed into a narrow column and a fatal error code is displayed. See https://www.screencast.com/t/WxsIEwHjd
October 28, 2020 at 2:05 am #21790Samuel
ParticipantHi Tom, (if you can delete my previous message please)
Here is a solution from WPML Support :
This is how the WP Show Posts plugin works. The lists are a CPT and its content needs to be translated as posts, and to display it properly the plugin author/developer needs to set the proper post ID inside the shortcode.
imho, this is a feature request that needs to go to the plugin author.
We found a workaround though:
– Add the following code to Appearance > Theme Editor > functions.phpadd_filter('wpsp_read_more_output', 'wpml_fix'); function wpml_fix($output) { $output = sprintf('<div class="wpsp-read-more"><a title="%1$s" class="%4$s" href="%2$s">%3$s</a></div>', the_title_attribute( 'echo=0' ), esc_url( get_permalink() ), __('Read more fixed', 'wpml-fix'), esc_attr( 'wpsp-read-more')); return $output; }
-Replace “Read more fixed” with the text you want to display in the front end
-Scan the theme for strings
-Translate the text in WPML > ST (it will show up under the domain “wpml-fix”)This is almost working, except it’s breaking how WPSP is displaying the button and how we asked him to behave (function for redirecting to custom URL). You can see a test example here : https://miviajeporcolombia.com/test-33-es/
If button style can be reproduce by CSS, I don’t know how to make the custom redirection function working in the spanish version of my website. The redirection function you gave me was in my function.php I moved it to Elements to be able to translate it. So I have now a Hook with the redirection function active in spanish version. But it’s not working.
October 28, 2020 at 2:58 am #21794Samuel
ParticipantSorry Tom, about that mess in my different message, but here is what I found :
My redirection problem was that as WPML didn’t allow me to translated url custom field (I have to see that with them) the url custom field in my spanish post translation was empty. SO, I added it manually. And now you can see what is happening : https://miviajeporcolombia.com/test-33-es/
When specifying url in post custom field, WPSP button’s style is display well BUT in French… it’s quite crazy what’s it’s happening here.
October 28, 2020 at 1:38 pm #21818Tom
KeymasterIf you want to use their fix, do this:
1. Use the latest development version: https://wpshowposts.com/wp-show-posts-1-2-0/
2. Use this function:
add_filter( 'wpsp_read_more_output', function( $output, $settings ) { return sprintf( '<div class="wpsp-read-more"><a title="%1$s" class="%4$s" href="%2$s">%3$s</a></div>', the_title_attribute( 'echo=0' ), esc_url( get_permalink() ), __( 'Read more', 'wp-show-posts' ), esc_attr( $settings['read_more_class'] ) ); }, 10, 2 );
That should retain all the styling and make the text discoverable by WPML.
-
AuthorPosts
- You must be logged in to reply to this topic.