-
AuthorPosts
-
November 26, 2014 at 7:49 pm #153650
Hello everyone, I’ve tried a lot to translate the line “I’ve read and accept the terms & conditions” in the checkout page and I haven’t been able to do so, I’ve tried the following code I saw in another page and it didn’t work (put it in the functions php of my child theme.
add_filter('gettext', 'translate_text'); add_filter('ngettext', 'translate_text'); function translate_text($translated) { $translated = str_ireplace('Billing Details', 'Detalles de compra', $translated); $translated = str_ireplace('I’ve read and accept the', 'He leido y aceptado expresamente los', $translated); $translated = str_ireplace('terms & conditions', 'términos y condciones', $translated); return $translated;
November 27, 2014 at 7:44 am #153972Hi there,
Thanks for posting in.
Have you tried using a translation plugin like WPML? You could use their manual string translation.
Or this,
add_filter ('gettext', 'x_translate_text', 99, 3 ); function x_translate_text ( $translated_text, $text, $domain ) { $translation = array ( 'Billing Details' => 'Detalles de compra', 'I\'ve read and accept the terms & conditions' => 'He leido y aceptado expresamente los términos y condciones' ); if( isset( $translation[$text] ) ) { return $translation[$text]; } return $translated_text; }
The $translation = array() contains the original string and the translation string. The original string should match the extract string you wish to translate. Any space or mismatched characters will invalidate the translation.
Hope this helps.
December 2, 2014 at 1:44 pm #156820Hello, Ive tried your solution but it didn’t work, does it go on the childtheme funcitions.php or where?
December 2, 2014 at 5:36 pm #157038Hi there,
You’ll need to place the given code in your child theme’s functions.php file. Also did you install the WPML plugin?
February 11, 2015 at 10:04 pm #204586Hello, your solution worked until tonights update, what can i do? Thanks in advance!
February 12, 2015 at 3:55 pm #205326Hi there,
Did it alter the any changes with your child theme funcitions.php? or was it a WPML compatibility issue?
if nothing was altered or you did not use the WPML, you could try clearing your cache if it helps.
Hope it works. if not let us know.
Thanks.
February 14, 2015 at 12:45 pm #206668Hello, here is how I have it added in my childrens theme functions.php
add_filter ('gettext', 'x_translate_text', 99, 3 ); function x_translate_text ( $translated_text, $text, $domain ) { $translation = array ( 'Billing Details' => 'Detalles de compra', 'I’ve read and accept the ' => 'He leido y aceptado expresamente los términos y condiciones' ); if( isset( $translation[$text] ) ) { return $translation[$text]; } return $translated_text; }
I’ve cleared the cache and this doesn’t work still, I don’t get it either why it stopped working! Thanks for your help!
February 14, 2015 at 1:08 pm #206680Sorry I forgot to say I don’t use WPML.
February 15, 2015 at 3:54 pm #207155Hi there,
Please use the exact code given 🙂
Please observe this :
$translation = array ( 'Billing Details' => 'Detalles de compra', 'I\'ve read and accept the terms & conditions' => 'He leido y aceptado expresamente los términos y condciones' );
Thanks!
February 24, 2015 at 12:47 pm #214174Hello, I tried with the complete code, with the exact code and still doesn’t work, here is the code:
add_filter ('gettext', 'x_translate_text', 99, 3 ); function x_translate_text ( $translated_text, $text, $domain ) { $translation = array ( 'Billing Details' => 'Detalles de compra', 'I\'ve read and accept the terms & conditions' => 'He leido y aceptado expresamente los términos y condiciones' ); if( isset( $translation[$text] ) ) { return $translation[$text]; } return $translated_text; }
What could the problem be?
February 25, 2015 at 4:27 am #214767Hi there,
In that case, would you mind providing us with login credentials so we can take a closer look? To do this, you can make a post with the following info:
– Link to your site
– WordPress Admin username / password
– FTP credentialsDon’t forget to select Set as private reply. This ensures your information is only visible to our staff.
Thank you.
March 5, 2015 at 7:31 pm #221374This reply has been marked as private.March 6, 2015 at 1:11 pm #221806Hi there,
Please check now, it’s translated.
Cheers!
March 6, 2015 at 2:23 pm #221844Thanks you are awesooome!
March 7, 2015 at 5:16 am #222135Thanks for kind words and you’re welcome.
-
AuthorPosts