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.

This topic contains 10 replies, has 2 voices.

Last updated by ericG-26 1 year ago.

Assigned support staff: Bobby.

Author Posts
September 25, 2018 at 8:13 am

ericG-26

I am trying to: translate static strings in theme

Link to a page where the issue can be seen: hidden link

I expected to see: translated string for testimonials

Instead, I got: same as English text.

September 26, 2018 at 2:09 am #2765536

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Hello,

Are you trying to translate the "Testimonials" title in the home page ?

i currently can see that it is translated, is the issue resolved ?

if i am looking at the wrong "Testimonials" string please provide me with the URL where i can find the correct string.

thank you !

September 26, 2018 at 10:04 am #2766774

ericG-26

sorry, for testing i have converted those in to custom field. now revert back to string. Please check now.
hidden link

September 26, 2018 at 6:43 pm #2768429

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Hello,

i can see that now it does not translate..to understand better , how are you reverting it to a string from a custom field..

from the page layout i can see that this is meant to be a custom field and to be translated from within the page editor rather than a string.

Note: please do go within WPML->String Translations->Translate texts in admin screens » and look for the string within the admin screens as well... it is a possibility the "testimonials" strings shown by string translation are not the correct string.

September 27, 2018 at 5:25 am #2769333

ericG-26

hello,
this meant to be static string. I am using this as <?php esc_html_e('Testimonials', 'snowxchain') ?>

but when i translate this from WPML->String Translations it doesn't effect on front end.

P.S. i have added credentials of site. can you also check there

September 27, 2018 at 6:26 pm #2771580

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

If possible please test by changing <?php esc_html_e('Testimonials', 'snowxchain') ?>

to

<?php __('Testimonials', 'snowxchain') ?>

and let me know your results

September 28, 2018 at 5:40 am #2772583

ericG-26

i already tried, but no success. it becoming quite urgent. Can you please help us to solve this ASAP?

and i given all required access, please change there as per needed. I have already backed up all files and DB

September 29, 2018 at 1:30 am #2774994

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Hello,

i believe the issue here is that these strings are from a custom field , while using ACF to create it

by taking a quick look at your code i believe you might need to wrap the strings within the array as well with gettext as shown here
-> https://wpml.org/forums/topic/custom-field-translation-4/#post-673238

$args = array(
        'post_type' => 'testimonial',
        'post_status' => array( 'publish' ),
        'posts_per_page' => -1
      );

your FTP credentials did not give me access to public_html and had to use WP File Manager to view them.

Another good documentation is found here:
https://wpml.org/documentation/getting-started-guide/translating-custom-fields/

let me know if wrapping the array helps and if it does not please provide me with the correct path to public_html

September 29, 2018 at 1:53 pm #2775652

ericG-26

this is not from custom field. This is static string.
and i believed you have checked on wrong line. i have attached line of code. also i have check ftp details it working fine. can you retry to connect?
and host name is snowchain.developstaging.com

here is path to public_html
/home/snowchain/public_html

October 1, 2018 at 5:29 pm #2778980

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Thank you for the additional info, i was able to access your FTP sucesfully.

i have gone to the hardcoded string and changed the string to "Testimonialsss"

my results are as following.

once the string is changed and i go to WPML -> String Translation i can see the string immediately picked up by WPML as expected

within String Translation there are 2 more strings with the word "Testimonials" , these strings are picked up even after they are deleted and even after the main string is changed to Testimonialsss with 3 "s" they remain with a single "s" unchanged.

i believe they must be hardcoded in your code somewhere else and constantly keep getting picked up but they are not the correct strings for your string in home-page.php thus translating them yields no results.

if i translate the top string thats showing in String Translation the String Translation is picked up correctly.

i believe these 2 strings as shown in my screenshot cause an issue and the correct string is not picked up.

The Solution :

I went to your hardcoded string and changed it again to "Testimonialss" so its slightly different from before.

it was picked up again correctly by WPML String Translation => i select the string and changed the default language within String Translation of that string to a random language.

this gives me the ability to translate it in "English " as well.

now the string is translated correctly with this workaround.

October 3, 2018 at 5:31 am #2783514

ericG-26

My issue is resolved now. Thank you!
i have solved this. It is due to function which i created