[wp-polyglots] Translating constructed sentences

Alex Hempton-Smith hempsworth at googlemail.com
Mon Mar 1 01:39:41 UTC 2010


Throughout my plugin I'm constructing sentences like this:

    if ($user_id == $author_id)
        $author = 'their own';
    elseif ($user_id == 0)
        $author = 'an';
    else
        $author = bp_core_get_userlink( $author_id ) . "'s";

    $action = bp_core_get_userlink( $user_id ) . ' likes ' . $author . ' <a
href="' . bp_activity_get_permalink($activity_id) . '">activity</a>';

What would be the best way of making this translatable? Something like this
perhaps:

    if ($user_id == $author_id) :
        $liker = bp_core_get_userlink( $user_id );
        $activity_url = bp_activity_get_permalink($activity_id);
        $action = sprintf(__('%s likes their own <a
href="%s">activity</a>'), $liker, $activity_url);
    elseif ($user_id == 0) :
        $liker = bp_core_get_userlink( $user_id );
        $activity_url = bp_activity_get_permalink($activity_id);
        $action = sprintf(__('%s likes an <a href="%s">activity</a>'),
$liker, $activity_url);
    else :
        $liker = bp_core_get_userlink( $user_id );
        $author = bp_core_get_userlink( $author_id );
        $activity_url = bp_activity_get_permalink($activity_id);
        $action = sprintf(__('%s likes %s\'s <a href="%s">activity</a>'),
$liker, $author, $activity_url);
    endif;

My only worry is that the sentences are almost identical, I don't want
translators having to do too much repetition.

-- Alex  (Hempsworth)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.automattic.com/pipermail/wp-polyglots/attachments/20100301/21a3ae09/attachment.htm>


More information about the wp-polyglots mailing list