Skip Navigation

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 -

Supporter timezone: Asia/Singapore (GMT+08:00)

This topic contains 6 replies, has 2 voices.

Last updated by luisT-15 1 year, 2 months ago.

Assisted by: Kor.

Author Posts
February 2, 2023 at 8:29 pm #12950839

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.

February 2, 2023 at 10:33 pm #12951265

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

February 3, 2023 at 3:58 am #12952159

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

February 3, 2023 at 8:58 am #12953669

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?

February 3, 2023 at 4:18 pm #12957423

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

February 3, 2023 at 8:44 pm #12958729

luisT-15

My issue is resolved now. Thank you, Kor!

February 10, 2023 at 4:11 pm #13008455
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!

New threads created by Kor and linked to this one are listed below:

https://wpml.org/forums/topic/split-how-to-translate-these-texts/

The topic ‘[Closed] How to translate these texts?’ is closed to new replies.