ideal identity
ideal identity

Reputation: 71

Internationalization of Labels Inside PHP Code

I'm trying to convert a legacy Wordpress theme to multilingual support. So far, I've managed to get it working with most of the parts but single.php file contains some code where I need your help. For example:

<?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>

I want to extract "Pages" word from the code above.

Also

How can I extract static text like "Your name", "Your email", etc from the code above?

<div class='create-comment'>
                        <?php $comment_args = array( 'title_reply'=>'Write a response',

'fields' => apply_filters( 'comment_form_default_fields', array(

'author' => '<div class="row"><div class="form-group col-sm-6"><label for="author">Your name</label> <span>*</span> <input id="author" name="author" type="text" class ="form-control" value="" size="30" /></div>',   

'email'  => '<div class="form-group col-sm-6"><label for="email">Your email</label> <span>*</span> <input id="email" name="email" class ="form-control" type="text" value="" size="30" /></div></div>',

'url'    => '' ) ),

'comment_field' => '<div class="form-group"><label for="comment">Your comment</label>  <span>*</span>  <textarea id="comment" name="comment" class ="form-control"  cols="45" rows="4" aria-required="true"></textarea>' .

            '</div>',

'comment_notes_after' => '',

);

comment_form($comment_args); ?>
                     </div>
                </div>

The code below works if text is not inside a php tag.

<?php _e( 'Contact Us', 'themeName' ); ?>

Any ideas? Thanks.

Upvotes: 0

Views: 54

Answers (1)

Minh Tri
Minh Tri

Reputation: 2471

You should use placeholder method.

Example:

'before' => sprintf( '<p><strong>%s:</strong> ', esc_html__('Pages', 'textdomain') ),

Upvotes: 1

Related Questions