[Support request] Translate Banner after “Add to cart”

Home Forums Support Translate Banner after “Add to cart”

  • This topic has 14 replies, 3 voices, and was last updated 1 month ago by Tom.
Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #1408346
    nik9

    Hello,

    I’m trying to translate the added to cart banner text to German. Unfortunately it’s not translated by default and with loco translate I do not find any value for this.

    Printscreen: https://ibb.co/PWZDXC2

    I was sure that this is Coming from WooCommerce but now I think it’s Coming from GP? Is this right?

    I’m playing around with the following code but no change at all:

    add_filter( 'wc_add_to_cart_message_html', 'my_changed_wc_add_to_cart_message_html', 10, 2 );
    function my_changed_wc_add_to_cart_message_html($message, $products){
    
        if (strpos($message, 'Continue shopping') !== false) {
            $message = str_replace("Continue shoppindddg", "Go the checkout", $message);
        }
    
        return $message;
    
    }

    There are actually 3 values to translate:
    – Continue Shopping
    – Item added to cart
    – Item

    When this is Coming from GP, how can I adjust the values? πŸ™‚

    Cheers

    #1409077
    David
    Staff
    Customer Support

    Hi there,

    thats is a translatable string – i assume its not being included in the German translation yet.

    You can try the gettext filter:

    add_filter( 'gettext', function( $translated_text ) {
        if ( 'Continue shopping' === $translated_text ) {
            $translated_text = 'Your new text here';
        }
    
        return $translated_text;
    } );
    #1409138
    nik9

    Hi Dave,

    But is this coming from GP? Because it’s not only “Continue Shopping” wrong. Also “Item added to cart” and “Item” are in the wrong language.

    So your filter works. But we had to this also for the others like “Item added to cart” and “Item” from this banner..

    Cheers

    #1409202
    David
    Staff
    Customer Support

    Yes, its a GP template.
    But it is output as a translatable string:

    https://developer.wordpress.org/reference/functions/_e/

    So it should grab the local variant – i can only assume it doesn’t exist.

    I’ll pass this onto Tom to get his input.

    #1409270
    nik9

    Okey, Thanks.

    Waiting for toms answer πŸ™‚

    Cheers

    #1409803
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    May be worth checking with Loco Translate. The strings should be translatable:

    _e( 'Continue Shopping', 'gp-premium' );
    _e( 'Item added to cart.', 'gp-premium' );
    _n( '%d item', '%d items', WC()->cart->get_cart_contents_count(), 'gp-premium' );
    #1409827
    nik9

    Thanks.

    But how? My Site language is “German (Switzerland)”.

    In GeneratePress Child translations are no strings as you mentoined.

    Cheers

    #1410100
    Tom
    Lead Developer
    Lead Developer

    I’m not sure how Loco Translate works. These translations are in the GP Premium plugin – not sure if that helps?

    #1410552
    nik9

    Hi Tom,

    Hmm can’t find these strings in GP Theme translation.

    May I can download the PO and MO file that you can see the problem?
    To reproduce only a blank site in German with GP and loco translate plugin is needed.

    Otherwise maybe I can translate these strings directly in GP somewhere or via php filter?

    Cheers.

    #1411452
    Tom
    Lead Developer
    Lead Developer

    Have you checked with their support?

    The translation wouldn’t be in the theme, it would be in the GP Premium plugin. Not sure if they separate things by theme/plugin?

    #1411767
    nik9

    Ah, I got it! Now it works. I reapply the site language and it works! πŸ™‚

    Thanks

    #1411883
    nik9

    Fun!

    It works for 99%…

    Now we have problems with the β€žitemβ€œ and β€žitemsβ€œ string.

    If the cart is emmpty and we add the first product to cart, the translations is right. If we now add a second item to the cart the string β€žitemsβ€œ appears.

    In loco translate I do not see a option to translate this string in GP premium translations file.

    _n( '%d item', '%d items', WC()->cart->get_cart_contents_count(), 'gp-premium' );

    #1412896
    Tom
    Lead Developer
    Lead Developer

    It may be something you need to bring up with them. _n is a core WordPress translation function where you can specific singular or plural.

    #1413183
    nik9

    Hello,

    Okey. Thanks. I will check that with loco translate. πŸ™‚

    Or can I translate the stuff in another way? Offline or so?

    Cheers

    #1413277
    Tom
    Lead Developer
    Lead Developer

    You can always sign up here: https://translate.generatepress.com/

    Then you can submit the translations and we can approve them for the plugin πŸ™‚

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