luisT-15
Hello,
I have some difficulty translating some texts in my theme, can you help me, please?
You can find some examples below.
File: content-single.php
Text: Back To Home
Code:
<a href="<?php echo esc_url( home_url( '/' ) ); ?>"><span class="glyphicon glyphicon-arrow-left" aria-hidden="true"></span> <?php _e( 'Back To Home', 'mad' ); ?></a>
--
File: post-content-mad.php
Text: Click here to visit
Code:
$linktext = apply_filters( 'mad_single_post_linktext', __( 'Click here to visit', 'mad' ) . ' ' . $title);
--
File: content-vsingle.php
Text: Check out this link!
Code:
<div class="ftext">Check out this link!</div>
Please teach me how to translate these texts so I can do the same in other theme files.
Thank you in advance.
luisT-15
I already found the first two, it was in the:
Theme and plugins localization -> Strings in the themes
But how to translate the other one?
File: content-vsingle.php
Text: Check out this link!
Code:
<div class="ftext">Check out this link!</div>
and:
File: inc/related-posts.php
Text: More like
Code:
<h4 class="maddos-post-header">More like <?php the_title();?>:</h4>
Thank you
Kor
Supporter
Languages:
English (English )
Timezone:
Asia/Singapore (GMT+08:00)
Hi there,
Thanks for contacting WPML support.
You need to enable "Text Translation/textdomain" as explained here https://wpml.org/documentation/support/enabling-text-translation-for-themes-not-compatible-with-wpml/ .
Once you've done that, perform a scan and look for the string in String Translations.
Let me know how it goes.
Thanks!
Kor
luisT-15
Thank you, Kor!
I fixed the problem by changing this:
<div class="ftext">Check out this link!</div>
To this:
<div class="ftext"><?php echo esc_html__( 'Check out this link!', 'customtranslation' ) ?></div>
Is the code fine?
Kor
Supporter
Languages:
English (English )
Timezone:
Asia/Singapore (GMT+08:00)
Hi there,
Thanks for your reply.
The code looks fine. Maybe you can use the same textdomain name as your theme so that when you scan the theme, it will appear in the string translation.
Thanks!
Kor
luisT-15
My issue is resolved now. Thank you, Kor!
luisT-15
Hello again, Kor.
Can you please help me how to translate this text?
jQuery('<button id="show_comments">Leave your feedback</button>').insertBefore(comment_div);
I tried this:
jQuery('<button id="show_comments"><?php echo esc_html__( 'Leave your feedback', 'customcode' ) ?></button>').insertBefore(comment_div);
But I think I can't use PHP inside a JS code.
The full code:
hidden link
Thank you in advance!