Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

How can I make $before (Books:) a translateable string

<?php echo get_the_term_list( $post->ID, 'book', 'Books: ',', ', ' ', '' ); ?>

with this method?:

<?php the_content(__('Read more...', "ft")); ?>
share|improve this question

1 Answer 1

up vote 2 down vote accepted

Use the __() function, just as you see in the the_content() example:

<?php 
echo get_the_term_list( 
    // ID
    $post->ID, 
    // taxonomy
    'book', 
    // Before
    __( 'Books: ', 'ft' ),
    // Separator, see http://core.trac.wordpress.org/ticket/7897
    __( ', ' ), 
    // After
    ' ', 
    // Looks like you've added an extra parameter?
    '' 
); 
?>

Note 1: I split the word "Books" from the part of the string that (probably) shouldn't need to be translated - i.e. the colon and space.); the two parts of the parameter are concatenated. (Ed: Per @Toscho's suggestion, I changed this)

Note 2: Looks like you've added an extra parameter to your call to get_the_term_list()

share|improve this answer
    
Thanks again Chip! I'm lost between commas, apostrophes and semicolons... –  elbatron May 18 '12 at 19:44
1  
No worries! That's why I like to break functions down, line-by-line, if they have too many parameters. For me, that makes it easier to follow what I'm defining for each parameter, with the inline comments. –  Chip Bennett May 18 '12 at 19:46
2  
Chip are you sure about the position of the : (double colon plus space)? This looks probably rather strange untranslated in a RTL language, doesn't it? –  toscho May 18 '12 at 19:49
    
@Toscho: no, actually, I'm not sure. That's why I made the note to point it out. :) –  Chip Bennett May 18 '12 at 19:50
    
Okay, I made the comma translatable too. Let's write showcases only. :) –  toscho May 18 '12 at 19:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.