How to transform hardcoded strings to polylang suitable translatable stings in WordPress private theme?

1.3k views Asked by At

I'm using "Polylang" plugin for multilingual site. So, there is some points not suitable for translating strings. Some of theme I could change for become suitable. However, for some others, I couldn't.

Here is the codes below.

template-contacts.php

Original code

if ( $message_btn ) : ?>
        <div id="contacts-modal" class="reveal-modal">
             <h1 class="entry-header"><?php _e( 'Send message', 'fluxus' ); ?></h1>
             <div class="modal-contents"></div>
             <a class="close-reveal-modal">&#215;</a>
        </div><?php
    endif;

I've changes code as

if ( $message_btn ) : ?>
    <div id="contacts-modal" class="reveal-modal">
         <h1 class="entry-header"><?php pll_e( 'Send message' ); ?></h1>
         <div class="modal-contents"></div>
         <a class="close-reveal-modal">&#215;</a>
    </div><?php
endif;

This works for regarding part. However, there is send message and view map buttons, and also "Use arrow %s keys for navigation" text in the footer. I couln't success to change, solve this parts. Here is the code:

if ( $has_map ) {
    $view_btn = '<a id="view-map" href="#" class="button icon-location">' . __( 'View map', 'fluxus' ) . '</a>';
} else {
    $view_btn = '';
}

/**
 * Show Send Message button only if there is a [contact-form-7] short tag
 * in the content.
 */
if ( preg_match('/\[contact\-form\-7.+?\]/is', $post->post_content) ) {
    $message_btn = '<a id="send-message" href="#" class="button icon-paper-plane">' . __( 'Send message', 'fluxus' ) . '</a>';
} else {
    $message_btn = '';
}

?>

How can I make changes on the part above?

1

There are 1 answers

0
Sofiane Achouba On

try to change __( 'View map', 'fluxus' ) to pll__( 'View map' )

and __( 'Send message', 'fluxus' ) to pll__( 'Send message' )

of course 'view map' and 'send message' need to be previously registered

pll_e( or _e( echo the string and __( orpll_( return the string.