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.

This topic contains 10 replies, has 2 voices.

Last updated by sylvainM-7 9 months, 1 week ago.

Assigned support staff: Rohan Sadanandan.

Author Posts
December 10, 2019 at 11:40 am #5099399

sylvainM-7

Tell us what you are trying to do?

Hello, I am just trying to translate a custom user role's name with WPML. The custom role exists but it seems impossible to translate it because I can't find the string corresponding to the new role in String Translation.

I deduce from this that it is maybe not possible to translate custom user role's names with WPML.

December 11, 2019 at 11:14 am #5106107

Rohan Sadanandan

Hello,

I've just checked this in a fresh installation & it's working fine.
I've followed the below steps:

1. Add the code to your theme/plugin's source code.
2. Navigate to Theme and plugins localization & select your theme/plugin & scan the same.
3. Once the scan is complete, navigate to WPML > String Translation & you will be able to see your string there.

Thanks,
Rohan

December 11, 2019 at 9:04 pm #5110589

sylvainM-7

Hello Rohan,

Thank you for your feedback and your test.

I also tried it on a fresh installation and I don't see any change.

Can I ask you what code you used and how you integrated it into WordPress?

With a plugin? Codes-snippets? Or maybe in functions.php?

Thanks in advance,
Sylvain

December 12, 2019 at 7:50 am #5112299

Rohan Sadanandan

Hello,

I've checked this code:

add_role(
'pro_customer_two',
__( 'PRO Customer 2' , 'test-domain'),
array(
'read' => true
)
);

This is a normal gettext() function.
So it will work in plugins, themes, functions.php, etc.

Thanks,
Rohan

December 16, 2019 at 1:01 pm #5138365

sylvainM-7

Hello Rohan,

Thank you for your additional feedback.

I check this this afternoon according to your instructions, on a new fresh installation and come back to you immediately afterwards.

See you later,
Sylvain

December 16, 2019 at 2:08 pm #5138825

Rohan Sadanandan

Hello,

Please let me know once you have checked the same.

Thanks,
Rohan

December 16, 2019 at 3:28 pm #5139407

sylvainM-7

Hello again,

Here are the results:

- With the same code as yours in functions.php: I can see the string in WPML string translation (with the "Code Snippets" plugin it was not working, maybe a too early call...). So I translated it BUT the transaltion has no impact. In user profile edit page, the role dropdown list shows "PRO Customer 2" and not its translation "Client PRO 2". Please could you check if your translation works on your side?

- By creating a new role with the famous plugin "User Role Editor", I cannot see the role created in WPML string translation (checked with PRO Customer 3 and PRO Customer 4)

I can give you access to this new fresh install if you want to see by yourself.

Thanks in advance for your help,
Sylvain

December 17, 2019 at 9:01 am #5144601

Rohan Sadanandan

Hello,

For the first question, could you please share the URL or screenshot of the pages so that I can understand better?

Regarding the second question, the User Role Editor plugin might not be compatible with WPML, and this might be the problem here.
The full list of our compatible plugins can be found here.
https://wpml.org/documentation/plugins-compatibility/

I'm enabling the private fields so that you can share the access details.

Thanks,
Rohan

December 18, 2019 at 8:58 am #5153553

sylvainM-7

Hello Rohan,

I wanted to keep you informed because I was finally able to make progress on this issue.

It would seem necessary to provide the translation context during the gettext() call.

So in our case:

_x('PRO Customer 2','User role')

For more information, you can follow this topic on the Capability Manager Enhanced plugin help forum: https://wordpress.org/support/topic/translation-of-custom-role-names-with-wpml/

Have a nice day and thank you again.

Sylvain

December 18, 2019 at 3:38 pm #5156363

Rohan Sadanandan

Hello,

Happy to know that you have found the solution & the issue is resolved.
Also thank you for sharing the solution.

You can close this ticket.
If you have any other issues, you can create a new ticket.
We are always happy to help you.

Thanks,
Rohan

December 18, 2019 at 3:45 pm #5156427

sylvainM-7

My issue is resolved now. Thank you!