WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: qTranslate] How to add php translation code into another php function (6 posts)

  1. dczepiel
    Member
    Posted 4 years ago #

    Hello,

    I know nothing about php.
    I tried to qTranslate all I could in my php files using the php function provided in FAQ - <?php _e("<!--:en-->english text<!--:--><!--:de-->german text<!--:-->"); ?>
    The problem is when I need to translate something that is already inside a php function like below:

    <?php comments_number('No Responses', 'One Response', '% Responses' );?>

    Is there a way to translate those 'No responses', 'One Response' etc. ?

  2. dczepiel
    Member
    Posted 4 years ago #

    anyone ?

  3. nouveller
    Member
    Posted 4 years ago #

    How about...

    <?php 
    
    	$no_responses = __("<!--:en-->english text<!--:--><!--:de-->german text<!--:-->");
    
    	$one_response = __("<!--:en-->english text<!--:--><!--:de-->german text<!--:-->");
    
    	$responses = __("<!--:en-->english text<!--:--><!--:de-->german text<!--:-->");
    
    	comments_number($no_responses, $one_response, '% $responses' );
    
    ?>

    I think __() returns the value where as _e( echoes it.

  4. dczepiel
    Member
    Posted 4 years ago #

    this looks pretty hard and I am not sure if that was the solution I was looking for but I will give it a try.

    I hoped there is a way to just insert the <!--:en-->english text<!--:--><!--:de-->german text<!--:--> part into an existing php function to make it work and be translated.

    But thanks !

  5. WebTechGlobal
    Member
    Posted 4 years ago #

    I've never seen translation used in that way.

    Are you using the POT and MO files?

    The whole point of the __() and putting text in it is to tell wordpress that string should be translated. It then looks into the MO files for the alternative doesnt it?

    If your way works then great but it looks like far too much work.

    WebTechGlobal

  6. WebTechGlobal
    Member
    Posted 4 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic