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: Unable to change original string from Theme

Solution:

Workaround in order to change a hardcoded string without changing it in the theme's actual code.

To do this go to WPML->Languages-> Add new language -> Add a random language .

Then scroll down and hide this language.

Now go back to WPML->String Translation->Select your string -> Change language of string to the newly added hidden language.

Now you will have an option to "translate" it on the original language of the theme.

Relevant Documentation: https://wpml.org/forums/topic/how-to-change-a-string-in-the-original-language-of-the-theme/

This topic contains 15 replies, has 2 voices.

Last updated by julianL-7 5 months, 2 weeks ago.

Assigned support staff: Andreas W..

Author Posts
April 26, 2019 at 3:38 am #3687471

julianL-7

I was using this solution:

https://wpml.org/forums/topic/how-to-change-a-string-in-the-original-language-of-the-theme/

As the person in the threat states, it is not working anymore. What's the workaround?

Thank you!

April 26, 2019 at 5:01 am #3687785

Andreas W.
Supporter

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

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

Hello,

Thank you for contacting WPML Support.

Do I understand right, that the theme option is not editable on your backend´s theme options?

As far I understand you added the string appear on String Translation by using the option "translate texts in admin screens"? then you edited the original string with the workaround from the mentioned ticket?

If so, possibly the string got overwritten with a theme update. The solution would be to create a Child theme and then change the string there. This way the theme will not be affected by updates.
https://developer.wordpress.org/themes/advanced-topics/child-themes/

You might also contact the theme authors and let them know that there are strings in the theme that are not able to be edited and you would kindly like to ask them to take the necessary changes inside of the theme´s template files.

Further, it would be helpful if you could provide me some screenshots from the string, so that I will be able to make myself a better picture of the issue.

Kind regards
Andreas

April 26, 2019 at 5:16 am #3687801

julianL-7

Dear Andreas,

thank you for your quick reply. The string is editable in the theme if I only have one language. (See screenshot1.)

However if I have a multilang (wpml) site, it is recommended to turn this off – in fact, I think the "editability" might even be the problem. Turned off, I can perfectly change all strings of the themes in different (translated) languages as described by you or in the documentation. However, I cannot change the "original string" anymore.

I attached two screenshots. E.g. if I want to rename the original content of the form "Counters section title" to "Statistics" this works in uni-language sites – however if I have a wpml site, it has no effect. I can translate it (in German it's the correct "Fakten") but in English it's the wrong "The numbers" instead of "Statistics".

A lot of googling led me to this solution: https://wpml.org/forums/topic/how-to-change-a-string-in-the-original-language-of-the-theme/ - this was perfect, however this is not working anymore.

Thank you for more hints
Julian

April 26, 2019 at 5:12 pm #3692575

Andreas W.
Supporter

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

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

Hello,

Thank you for your message.

If I understand right the string "The numbers" is hard-coded inside the theme and there is not any way to edit it on back end inside of the theme options, correct me if I am wrong?

In this case the theme template file containing the string will need to be edited. This is why I asked you to reach out to the theme authors. You could edit this yourself with the guidelines in the following documentation, but you will need to create a Child Theme, as a theme Update would overwrite these changes.
https://developer.wordpress.org/themes/advanced-topics/child-themes/

In fact this is not a WPML issue, as the string is available for transaltion, but it seems as far I understand the theme authors did not provide any option to change the string in their theme options. Please ask them for assistance on this matter.
hidden link

Let me know if I am mistaking here.

Kind regards
Andreas

April 27, 2019 at 12:09 am #3693611

julianL-7

Hi Andreas,

on the contrary: There is an option to change all these strings in the themes‘ options. If I do that, however, WPML won’t translate anymore.

I can give you a User to have a look if you want?

Best
Julian

April 29, 2019 at 3:24 pm #3704925

Andreas W.
Supporter

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

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

Hello!

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.

Maybe I'll need to replicate your site locally. For this, I’ll need to temporarily install a plugin called “Duplicator” on your site. This will allow me to create a copy of your site and your content. Once the problem is resolved I will delete the local site. Let me know if this is ok with you.

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

In order to save some time, please also make sure to install a copy of the theme on the following test-site. I will test it for compatibility and once we have pointed out the issue, we are able to work on a solution together with the theme author's cooperation.

One Click Login:hidden link

Please leave me short notification once the Trawell 1.4 theme is ready for testing.

Kind regards
Andreas

April 30, 2019 at 9:57 am #3710215

julianL-7

Andreas,

actually, I found kind of a workaround: I set "Somali" as the primary language in wpml and then hide it. That way, English is no longer the original but just another translation, like Chinese, German and so on. Now I am able to "change" (i.e. translate) the strings in the theme again.

I don't know if that's good - or breaks anything else though. What do you recommend?

Best
Julian

April 30, 2019 at 3:05 pm #3712637

Andreas W.
Supporter

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

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

Hello,

Thank you for your messsage.

Indeed, this is the proper workaround as my colleague Bobby mentioned in this ticket, which you linked inside of your first message.
https://wpml.org/forums/topic/how-to-change-a-string-in-the-original-language-of-the-theme/

My apologies for the misunderstanding, I was thinking that you tried this workaround and it did not solve the issue.

In fact, the theme seems not to be 100% compatible with WPML which for I would like to invite you to install a new copy on the following test site. This way I will be able to investigate the issue on a new installation of WordPress and escalate problems to our compatibility team, which will contact the theme author's in order to solve the issue.

One Click Login:hidden link

Let me know if your run into any further issues when translating the theme. About the theme options I would advise you to keep the translation section disabled, in order to leave those decissions to WPML.

Also, could you please increase your PHP Memory Limit to 512M and the WP Memory limit to 256M? 128M is the minimum required by WPML.
Your current values are:

MemoryLimit 256M (php.ini)
WP Memory Limit 40M (wp-config.php)
Add this code to your wp-config.php to increase WP memory:

/* Memory Limit /
define('WP_MEMORY_LIMIT', '256M');

Paste it just before:

/ That's all, stop editing! Happy blogging. /

These settings can be limited directly by your hosting provider, so I recommend you to contact and ask them to modify them directly.
If you can get even higher values It would be great.

https://wpml.org/home/minimum-requirements/
Note: WPML needs a minimum WP Memory limit of 128M to work only under a minimal environment, it means,
with a default theme and not other plugins installed.

Please also change the value of "maxInputVars" inside of your php.ini file. You are currently using a value of 1000. I would recommend you to change this setting to at least 3000.
You can find the php.ini file on your server inside the folder for your currently used PHP version 7.2.13.

In case of any doubt please contact your hosting provides and ask for assistance.

Kind regards
Andreas

May 2, 2019 at 7:44 am #3722385

julianL-7

Dear Andreas,

thank you very much for your help.

Now, I also have to set the primary language to somali – which is a little weird, because e.g. the default redirect is to locolust.com/so/ (you can see that very brief in the url bar).

I uploaded the theme to your test environment.

I will also try to get a bigger machine and set your settings accordingly. This will take me a couple of days though.

Thank you very much
Julian

May 2, 2019 at 4:10 pm #3726611

Andreas W.
Supporter

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

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

Hello Julian,

You can disable the /so inside of the URL by going to WPML -> Languages -> Site URL structure and deselect the checkbox for "use directory for default language".

This way your default language should appear as hidden link only.

Further, I have been testing the theme on the provided test site, adn I was not able to add the strings for the theme to String Translation manually, by using the option "translate strings in admin screens" at the bottom of the String Translation screen.

Anyhow, I achieved to add and translate them after addign a custom XML configuration.
https://wpml.org/documentation/support/language-configuration-files/#admin-texts

Please add this config to your site at WPML -> Settings -> Custom XML Config. For further parts of the theme this cofnig will need to be adjusted with the respective string keys, which you can find at "translate texts in admin screens" under the domain name trawell_settings.

<wpml-config>
    <admin-texts>
        <key name="trawell_settings">
            <key name="tr_home_cover_title" />
            <key name="tr_home_cover_text" />
            <key name="tr_home_about_title" />
            <key name="tr_home_about_button_1_text" />
            <key name="tr_home_about_button_2_text" />
            <key name="tr_home_posts_title" /></key>
    </admin-texts>
</wpml-config>

Let me know if you do have any further question.

Kind regards
Andreas

May 3, 2019 at 4:27 am #3730721

julianL-7

Dear Andreas,

If I deactivate “use directory” I’m running into “too many redirects”. Maybe this is because I don’t have a single page or post in Somali. (Because I don’t want that language, it is only there and primary because of that hack to translate the themes’ strings.)

When I use your XML, I can disable Somali again?

Thanks and best
Julian

May 3, 2019 at 4:34 am #3730731

julianL-7

And just another quick question: How do I get the xml confit there – it doesn’t appear in my main installation. (I don’t use translation management though, because I find it a little annoying.)

May 3, 2019 at 4:01 pm #3736499

Andreas W.
Supporter

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

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

Hello,

Thank you for your message.

Yes, indeed. If the XML Config is added you should not need to use the workaround with Somali. Actually, this workaround would only be necessary to change the original string for the default language.

In order to use the XML Config Translation Management is mandatory. I have escalated the issue to our compatiblity team in order to consult them about a global config file that should solve any problems.

I will contact you as soon I receive any feedback.

Kind regards
Andreas

May 4, 2019 at 5:22 am #3739255

julianL-7

Hello Andreas,

I‘m a little lost now. I did all you said, deleted Somali, installed Translation Management etc. but now my translations/edits on the (English) Homepage are gone again.
Now I read your post carefully again and realize „...workaround would only be necessary to change the original string for the default language“. <- That‘s the (only) thing I want to achieve, right.
So in the end, I do need a (hidden) Somali, set it to primary, after all?

Best
Julian

May 6, 2019 at 3:55 pm #3750709

Andreas W.
Supporter

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

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

Hello,

I am sorry for the confusion.

Indeed, the workaround with changing the default language in order to edit original strings is not a common solution, as the main issue here is that theses strings are not editable on the backend of the theme. Yes, in order to change them you would need to apply our worarround but as mentioned earlier I would advise you to reach out to the theme support and explain the situation.

The custom XML config which I applied will only be necessary to translate the strings into other languages and I have escalated this ticket to our compatiblity team in order to consult about a global solution for such language configuration file for this theme as you mentioned that you do not wish to use our Translation Management Plugin.

I hope this clarifies the issue and answers your question.

Kind regards
Andreas