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 thread is resolved. Here is a description of the problem and solution.

Problem: How to change original strings that are hardcoded in the theme or plugin?

Solution: In general those strings will need to be edited inside the template files. WPML does not by default offer an option to change or edit orignal strings, rather than translate them into another language.

Anyhow, there is a workaround: 1) Go to WPML > Languages > Add new language and add a random language.

2) Scroll Down and hide the new language.

3) Go to String Translator and find the string you want to edit the default string.

4) Select it and click on "change selected strings language" and change the language to the new "dummy" language we just added.

5) Now you should be able to see the option to "translate" it in the orginal language.

Relevant Documentation: Relative ticket: https://wpml.org/forums/topic/change-original-string-translation

This topic contains 6 replies, has 2 voices.

Last updated by julienG-23 5 months ago.

Assigned support staff: Andreas W..

Author Posts
May 7, 2019 at 4:35 pm #3760583

julienG-23

Hello everyone,

I want to make the same thing as Polylang does for strings translation.
The purpose is to put the key in the code but I want to translate it. For exemple :

__('hello', 'mydomain')

I can translate hello to "bonjour", but if the client choose to update "hello", he could not. He has to ask the developper to update his code and it's a real problem for us.

Is there a solution to that ?

May 7, 2019 at 4:52 pm #3760727

Andreas W.
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

Thank you for contacting WPML Support.

In fact, as long a GetText call is placed inside the code for each string the string will be available for translation with WPML.

The Theme and Plugin Localization of WPML makes it possible to scan for new strings.
https://wpml.org/documentation/getting-started-guide/theme-localization/

Those strings will then be able to translate with our String Translation module.
https://wpml.org/documentation/getting-started-guide/string-translation/

Further, here you will be able to add strings from plugin and theme options which are able to be added from the option "translate strings in admin texts" at the bottom of the String Translation window.

Here our documentation about how to proper set GetText calls for strings inside of your theme:
https://wpml.org/faq/language-setup/

I hope this answered your question.

Kind regards
Andreas

May 10, 2019 at 1:39 pm #3785073

julienG-23

Hello,

thanks for your answer. I think you don't really answer to my question.

I already use GetText, Strings translations and all configuration you give to me.

The fact is I want to translate the key of my word.

In your example :

<?php _e('Roadmap','theme-text-domain') ?>

I want to update the string "Roadmap" directly in WordPress, not update my code.

Do you undestrand what I mean ?

Kind regards

May 10, 2019 at 5:14 pm #3786997

Andreas W.
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

I am sorry, but I cannot follow. You wish to translate the string with WPML or you wish to change the string inside of theme or plugin options?

Could you please send me screenshots fro the "Raodmap" string from front end and backend?

I would like to request temporary access (wp-admin and FTP) to your site to take a better look at the issue. It would be better to a testing site where the issue is replicated.

You will find the needed fields for this below the comment area when you log in to leave your next reply. The information you will enter is private which means only you and I can see and have access to it.

IMPORTANT

Please make a backup of site files and database before providing us access.
If you do not see the wp-admin/FTP fields this means your post & website login details will be made PUBLIC. DO NOT post your website details unless you see the required wp-admin/FTP fields. If you do not, please ask me to enable the private box. The private box looks like this:
hidden link

Kind regards
Andreas

May 16, 2019 at 8:26 am #3823137

julienG-23

Hi Andreas,

I fear I cannot give you access to the website, as it is a confidential project for one of our clients.

Let me try to describe my problem in more detail :

- In the WordPress code, I currently have to add a text string, like the text « Roadmap » in this example : <?php _e(‘Roadmap’,‘theme-text-domain’) ?> (it's that you call "GetText")
- The problem is, that this string in the code is already a text set in a specific language, here in english
- In the WordPress back-office, in the WPML string translation section, my English text « Roadmap » cannot be edited, I can only change the translations of the text (French, German, etc…)
- This is a problem because if our client wants to update the English string, he cannot do it in the WordPress back-office

What I would like to do :

In the PHP code, be able to set a general key, that has nothing to do with a specific language. For example, I would like to be able to set a key named ‘block_title’, that would allow me, in the WordPress back-office, to define the text of this key in every language.
So in the back-office I would define that ‘block_title’ —> EN = « Roadmap » / FR = « Planning » / DE = « Zeitplan »
In this way, our clients would be able to edit the string in all languages, without having to access the PHP code.

Again, here is an example of how Polylang manages this key-string relation, I would like to reproduce exactly the same in WPML.

May 16, 2019 at 2:54 pm #3827183

Andreas W.
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

Thank you for your message.

WPML helps you translated your default strings to a secondary language. If you wish to edit the main language you are techincally changing the original hardcoded strings which should be done within the code and that is why WPML does not offer this function as of now.

But we can try this workaround: 1) Go to WPML > Languages > Add new language and add a random language. 2) Scroll Down and hide the new language. 3) Go to String Translator and find the string you want to edit the default string. 4) Select it and click on "change selected strings language" and change the language to the new "dummy" language we just added. 5) Now you should be able to see the option to "translate" it in the orginal language.

Relative ticket:
https://wpml.org/forums/topic/change-original-string-translation/

I hope this will answer your question and solve the issue.

Kind regards
Andreas

May 21, 2019 at 6:59 am #3852379

julienG-23

My issue is resolved now. Thank you!