• Hey,

    first of all – thank you for this awesome plugin ??

    I have some issue with translating my page. I can’t translate some strings (ex. text on buttons). I tried to register those strings with function and then translate them but nothing happened. Next I try to translate them in .po file but again – nothing happened.

    Finally, I used this function to get those text translated:

    function change_translate_text( $translated_text ) {
    	if ( $translated_text == 'View' ) {
    	$translated_text = 'new text';
    	}
    	return $translated_text;
    }
    add_filter( 'gettext', 'change_translate_text', 20 );

    Unfortunatelly, I have 3 languages on my site and I need some help with this code – it should detect user language and then display correct translation. I was trying to add:

    $curlang = pll_current_language();
    if ($curlang=='ru')

    but this also didn’t work.

    • This topic was modified 7 years, 7 months ago by mathew07.
Viewing 1 replies (of 1 total)
  • Thread Starter mathew07

    (@mathew07)

    Hello again,

    I couldn’t edit previous post so I had to post new one.

    I edit my code and now it looks like this:

    add_filter('gettext', 'translate_text3');
    add_filter('ngettext', 'translate_text3');
    function translate_text3($translated) {
    		if ( pll_current_language() == 'ru' ) {
    			$translated = str_ireplace('View Cart', 'ten', $translated);   
    	}
    		else { 
    			$translated = str_ireplace('View Cart', 'inny', $translated);
    	}
    return $translated;
    }

    but stil no luck. It seems that parameter pll_current_language is not working at all. Any help with that will be appreciated ??

    BR, Mat

Viewing 1 replies (of 1 total)
  • The topic ‘Function – string translation’ is closed to new replies.