Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1389953

    gretar
    Participant

    Hello

    I have a site, http://www.jotunn.is and when displaying cross sells I can not translate this text You May Be Interested In…

    I have this function in my child theme functions.php but it does not work

    add_filter('gettext', 'x_translate_text' , 20, 3);
    add_filter('ngettext', 'x_translate_text' , 20, 3);
    function x_translate_text ( $translated_text, $text, $domain ) {
    
    	$translation = array (
    		'%s has been added to your cart.' => '%s er kominn í körfuna þína.',
    		'Your cart is currently empty.' => 'Karfan þín er tóm eins og er',
    		'Return To Shop' => 'Fara aftur í vefverslun',
    		'%s have been added to your cart.' => '%s eru komin í körfuna þína.',
    		'You are now logged in as <strong>%s</strong>' => 'Þú ert núna skráð/ur inn sem <strong>%s</strong>',
    		'View Cart' => 'Skoða körfu',
    		'%s removed. %sUndo?%s' => '%s fjarlægt úr körfunni þinni. %sSækja vöru aftur í körfu?%s',
    		'Postcode / ZIP' => 'Póstnúmer',
    		'Clear' => 'Hreinsa',
    		'Related Products' => 'Tengdar vörur',
    		'You May Be Interested In…' => 'Þú gætir einnig haft áhuga á…',
    		'Apply Coupon' => 'Nota afsláttarkóða'
    	);
    
    	if( isset( $translation[$text] ) ) {
    	return $translation[$text];
    	}
    
    	return $translated_text;
    }

    Can I get some help on this ?

    #1390053

    Christian
    Moderator

    Hey there,

    Please follow this translation instruction https://community.theme.co/kb/translation/

    Thanks.

    #1390149

    gretar
    Participant

    I have everything translated in PoEdit files but this string is not in the language files and that is why I have this function in functions.php to translate extra strings not found in the language files for the theme. I have a child theme where the language files are stored so they are not overwritten when the theme is updated.

    So please help me with this function or tell me where exactly I can translate this string and also have it so that it does not get overwritten in the next update.

    #1390266

    Christian
    Moderator

    That string is available in wp-content\themes\x\framework\lang\x.pot as You May Be Interested In&hellip; (see attachment)

    Try replacing You May Be Interested In… in your code with the proper string You May Be Interested In&hellip;

    Thanks.

    #1390268

    gretar
    Participant

    Thanks ! the … was exactly what I was missing.

    #1390364

    Christian
    Moderator

    You’re welcome.