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 2 replies, has 1 voice.
Last updated by Nikhil Vishwanath 11 hours, 26 minutes ago.
Author | Posts |
---|---|
January 24, 2025 at 7:17 am #16630403 | |
Nikhil Vishwanath |
Background of the issue: Symptoms: Questions: |
January 24, 2025 at 9:04 am #16630688 | |
Dražen Supporter
Languages: English (English ) Timezone: Europe/Zagreb (GMT+01:00) |
Hello, Thanks for contacting us. You can wrap each text as a string and make it translatable via gettext and between them show a variable, or you can include a variable inside translatable text. Let’s say you have a string like the following: echo 'Welcome $name.' In this case, $name is the variable and you shouldn’t include it in the translation. Instead, you should use a placeholder in place of the variable. Then, you can use the printf() or sprintf() function to output the translated string with the variable value inserted. printf( /* translators: %s: Name of a person */ __( 'Welcome %s.', 'your-text-domain' ), $name ); Now, the translator can translate “Welcome %s” as an entire phrase. The PHP printf() function inserts the name of the person back into the string. Regards, |
January 24, 2025 at 11:31 am #16631129 | |
Nikhil Vishwanath |
Hi, Thanks for your response. We are using the following to translate our text and return it as a response to our ajax call - <php $translation_array = array( 'apply_translation' => __( 'The next section '.$next_lesson_title .' will become available starting '.$lesson_access_date, 'astra-child' ) ); Can you please let me know how I can integrate or make changes to our code using your example? Thanks, |