- This topic has 14 replies, 3 voices, and was last updated 3 years, 7 months ago by Tom.
-
AuthorPosts
-
August 18, 2020 at 1:03 pm #1408346nik9
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
– ItemWhen this is Coming from GP, how can I adjust the values? ๐
Cheers
August 19, 2020 at 2:25 am #1409077DavidStaffCustomer SupportHi 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; } );
August 19, 2020 at 3:18 am #1409138nik9Hi 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
August 19, 2020 at 4:15 am #1409202DavidStaffCustomer SupportYes, 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.
August 19, 2020 at 5:14 am #1409270nik9Okey, Thanks.
Waiting for toms answer ๐
Cheers
August 19, 2020 at 8:59 am #1409803TomLead DeveloperLead DeveloperHi 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' );
August 19, 2020 at 9:12 am #1409827nik9Thanks.
But how? My Site language is “German (Switzerland)”.
In GeneratePress Child translations are no strings as you mentoined.
Cheers
August 19, 2020 at 1:15 pm #1410100TomLead DeveloperLead DeveloperI’m not sure how Loco Translate works. These translations are in the GP Premium plugin – not sure if that helps?
August 20, 2020 at 1:16 am #1410552nik9Hi 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.
August 20, 2020 at 9:36 am #1411452TomLead DeveloperLead DeveloperHave 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?
August 20, 2020 at 1:51 pm #1411767nik9Ah, I got it! Now it works. I reapply the site language and it works! ๐
Thanks
August 20, 2020 at 3:41 pm #1411883nik9Fun!
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' );
August 21, 2020 at 8:50 am #1412896TomLead DeveloperLead DeveloperIt may be something you need to bring up with them.
_n
is a core WordPress translation function where you can specific singular or plural.August 21, 2020 at 1:20 pm #1413183nik9Hello,
Okey. Thanks. I will check that with loco translate. ๐
Or can I translate the stuff in another way? Offline or so?
Cheers
August 21, 2020 at 3:23 pm #1413277TomLead DeveloperLead DeveloperYou can always sign up here: https://translate.generatepress.com/
Then you can submit the translations and we can approve them for the plugin ๐
-
AuthorPosts
- You must be logged in to reply to this topic.