Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
The client is trying to translate the 'Roles:' string from the Genesis theme, which is added via the functions.php file. The string is not appearing in WPML's String Translation search even after scanning the theme and child theme.
Solution:
1. Enable the 'Look for strings while pages are rendered' option in WPML >> String Translation page.
2. Visit the page where the string appears on the front end.
3. Return to the WPML >> String Translation page and search for the 'Roles:' string.
4. Translate the string and then disable the auto-registration option.
If this does not resolve the issue, install the String Locator plugin (https://wordpress.org/plugins/string-locator/) and search for the text in theme or theme bundled plugins files. Ensure the 'Roles:' string is wrapped in the gettext function, as detailed in the documentation (https://wpml.org/documentation/support/translating-the-theme-you-created/#wrap-all-texts-in-gettext-calls).
Alternatively, replace the existing code in functions.php with:

/* Add Trustee Roles to Trustee Single pages*/<br />add_filter( 'genesis_post_meta', 'monochrome_display_custom_tax' );<br />function monochrome_display_custom_tax($post_meta) {<br />    $roles_string = __('Roles:', 'themedomain');<br />    $post_meta = '[post_terms taxonomy="trustee_role" before="'.$roles_string.' "]';<br />    return $post_meta;<br />}

Then, scan the theme again and translate the 'Roles:' string via WPML >> String Translation page.

If the solution provided here does not resolve your issue, or if it seems outdated or irrelevant to your case, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If needed, please open a new support ticket at WPML support forum for further assistance.

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.

Tagged: 

This topic contains 4 replies, has 0 voices.

Last updated by barjD-2 4 days, 2 hours ago.

Assisted by: Noman.

Author Posts
December 17, 2024 at 8:28 am #16520202

barjD-2

I have another instance of the word "Roles:" which seems to come from the Genesis theme somewhere. It is not visible in a string search, even after I have scanned the theme and child theme to search for strings. I am not sure if this requires a new ticket, or if it can be resolved in this ticket, being that it is a similar issue.

Can you confirm?

I have attached screenshots to show what I mean.

Visible on this page: hidden link

16518720-genesis_monochrome_entry_term_string_no_results_2024_12_16_at_11.27.41_AM.png
16518720-genesis_monochrome_entry_terms_string_not_translated_2024_12_16_at_11.27.00_AM.png
December 17, 2024 at 9:01 am #16520414

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for contacting WPML Support. Could you please follow the below steps and let me know how it goes:

1. Go to the WPML >> String Translation page and in the Auto register strings for translation section, enable the ‘Look for strings while pages are rendered’ option.
2. Re-visit the page on the front end where the string appears.
3. Re-visit the WPML >> String Translation page and search for that string.
4. Translated the string.
5. After translating the string, unchecked the auto-registration option.

If the above steps don’t help, I suggest you please install the String Locator plugin: https://wordpress.org/plugins/string-locator/ and search that text in theme or theme bundled plugins files and make sure the “Role” string is wrapped in gettext function. Here is a doc for more details: https://wpml.org/documentation/support/translating-the-theme-you-created/#wrap-all-texts-in-gettext-calls

Please let me know the results,
Thank you for your cooperation

December 17, 2024 at 8:04 pm #16523381

barjD-2

Thank you again, I really appreciate your assistance.

I figured out where the "Roles:" string is coming from. I think it is in our functions.php file which has the following:

/* Add Trustee Roles to Trustee Single pages*/
add_filter( 'genesis_post_meta', 'monochrome_display_custom_tax' );
function monochrome_display_custom_tax($post_meta) {
$post_meta = '[post_terms taxonomy="trustee_role" before="Roles: "]';
return $post_meta;
}

I tried to change it like this, but I got a syntax error 🙁

$post_meta = '[post_terms taxonomy="trustee_role" before=__("Roles: ",'genesis')]';

So then I did this....

$post_meta = __('[post_terms taxonomy="trustee_role" before="Roles: "]');

But the string I got was:

[post_terms taxonomy="trustee_role" before="Roles: "]

I attached a screenshot so you could see what I mean.

Could you kindly help us figure out how to get "Roles:" into the gettext function?

Screenshot 2024-12-17 at 12.01.32 PM.png
December 18, 2024 at 6:35 am #16524237

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thanks for the details. Could you please try to follow the below steps:

1. Replace below code:

add_filter( 'genesis_post_meta', 'monochrome_display_custom_tax' );
function monochrome_display_custom_tax($post_meta) {
$post_meta = '[post_terms taxonomy="trustee_role" before="Roles: "]';
return $post_meta;
}

With:

/* Add Trustee Roles to Trustee Single pages*/
add_filter( 'genesis_post_meta', 'monochrome_display_custom_tax' );
function monochrome_display_custom_tax($post_meta) {
	$roles_string = __('Roles:', 'themedomain');
	$post_meta = '[post_terms taxonomy="trustee_role" before="'.$roles_string.' "]';
	return $post_meta;
}

2. Scan the theme in which you update the above code.

3. Search for “Roles:” string and add the translation from WPML >> String Translation page.

Please let me know the results,
Thank you

December 18, 2024 at 9:32 pm #16527904

barjD-2

This worked! Thank you very much!