[Resolved] WPML and "Read more…" translation problems

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support WPML and "Read more…" translation problems

Viewing 15 posts - 16 through 30 (of 35 total)
  • Author
    Posts
  • #21147
    Samuel
    Participant

    Just 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.

    #21153
    Samuel
    Participant

    WPML Support ask for your contact @Tom, are you ok to send your email to me ?

    #21175
    Tom
    Keymaster

    Absolutely, they can contact us through our form here: https://wpshowposts.com/contact/

    #21350
    Samuel
    Participant

    Hi @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 !

    #21430
    Tom
    Keymaster

    We haven’t heard from them yet. From their latest reply, it seems they’re still looking into the issue.

    #21510
    Samuel
    Participant

    Hi 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…

    #21607
    Samuel
    Participant

    Hi @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/)

    #21655
    Tom
    Keymaster

    Perhaps 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 );
    #21713
    Samuel
    Participant

    Hi 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 with fr_FR but it didn’t work either.

    #21717
    Gary
    Participant

    I 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.

    #21755
    Tom
    Keymaster

    When you say it broke everything, what do you mean? What did it break, exactly?

    Let me know 🙂

    #21775
    Gary
    Participant

    The page gets compressed into a narrow column and a fatal error code is displayed. See https://www.screencast.com/t/WxsIEwHjd

    #21790
    Samuel
    Participant

    Hi 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.php

    add_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.

    #21794
    Samuel
    Participant

    Sorry 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.

    #21818
    Tom
    Keymaster

    If 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.

Viewing 15 posts - 16 through 30 (of 35 total)
  • You must be logged in to reply to this topic.