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.

Sun Mon Tue Wed Thu Fri Sat
- 11:00 – 15:00 11:00 – 15:00 11:00 – 15:00 11:00 – 15:00 11:00 – 15:00 -
- 16:00 – 20:00 16:00 – 20:00 16:00 – 20:00 16:00 – 20:00 16:00 – 20:00 -

Supporter timezone: Europe/Rome (GMT+02:00)

This topic contains 15 replies, has 3 voices.

Last updated by Laura 11 months, 3 weeks ago.

Assisted by: Laura.

Author Posts
May 8, 2024 at 9:26 am #15605138
nickG-26

I Wanted to use a translation plugin to translate my website.
Previously I was already using the WooCommerce Multilingual & Multicurrency plugin and was happy about it.

I dicided to buy a plan with you to use the translation functionality as well.
After that i installed the installer plugin, and used that to install:
- WPML Multilingual CMS
- WPML String Translation

Whenever I install the second one, WPML String Translation, my site gets an Fatal error, and I have to deactivateone of the two latter plugins to get my site working again.

I checked the requirements defined at https://wpml.org/home/minimum-requirements/
All requirements are met.

After this I checked for theme compatibility using your online tool, and the theme i'm using, and other themes installed are also supported.

Then I checked for plugin compatibility with the online tool, and found some plugins that i'm using were'nt defined in the tool.
I tried deactivating those plugins, but still no result.

My conclusion was that it does not have anything to do with theme/plugin compatibility.

Then i looked at the php error logs to see whats going on there and found out that whenever I have the combination of WPML Multilingual CMS and WPML String Translation plugins active I get errors stating that it cannot redeclare certain functions:
[08-May-2024 08:34:07 UTC] PHP Fatal error: Cannot redeclare icl_st_init() (previously declared in /home/kukudu5/public_html/kukudushi.com/wp-content/plugins/wpml-string-translation/inc/functions.php:17) in /home/kukudu5/public_html/kukudushi.com/wp-content/plugins/wpml-string-translation/inc/functions.php on line 17

I edited the code in the file by using the php function_exists for the function in question and then i got this error:
[08-May-2024 08:41:58 UTC] PHP Fatal error: Cannot redeclare wpml_st_init_register_widget_titles() (previously declared in /home/kukudu5/public_html/kukudushi.com/wp-content/plugins/wpml-string-translation/inc/functions.php:124) in /home/kukudu5/public_html/kukudushi.com/wp-content/plugins/wpml-string-translation/inc/functions.php on line 124

The weird thing is that is is complaining that the function is already declared, but when you look at the full error message, it says it is already declared in exactly the same php file.

Now I'm thinking that for some reason it is including the same plugin twice or something like that.
I deleded and reinstalled both plugins a couble of times already but with no results..
The weird thing is that when i ONLY have the WPML String Translation plugin active, I don't get any errors.
The same thing goes for WPML Multilingual CMS.
It's the combination of those two that result in a Fatal Error.

What can I do to resolve this issue?

I'm using a custom child theme based on the theme: Hello Elementor.

Heres a full list of my installed plugins for reference:

[removed]

New threads created by Laura and linked to this one are listed below:

https://wpml.org/forums/topic/cannot-redeclare-icl_st_init/

May 8, 2024 at 4:40 pm #15607341

Marcel
WPML Supporter since 02/2019

Languages: English (English ) German (Deutsch )

Timezone: Europe/Madrid (GMT+02:00)

Hi,

Yes, the function seems detected as it has already been declared in the same file.

Please replace the WPML String Translation folder and re-install it again. Make sure to take a complete backup of your entire site before performing this action.

If this doesn't help, please let me know. Then, we can look closer at a local site copy or a staging environment.

Best Regards,
Marcel

May 8, 2024 at 7:19 pm #15607706

nickG-26

I've already tried this a couple of times..
It doesn't make a difference.

Please note that I'm running PHP8.2 on my hosting server.

What else can you suggest?

May 8, 2024 at 8:42 pm #15607834

nickG-26

Ok, after hours and hours of trying everything I could think of I found the solution.
I want to share it so that other people don't have to go through the same trouble as I did.

Previously I developed a fully custom product page, fully coded by myself so I had full freedom in every aspect.

I used php, html, js(jquery) and css to achieve this.
After some time I've downloaded the WPML Language/Currency plugin to be able to easily switch between currencies on my website.

Because my shop page is completely custom I had to incorporate the WPML logic into my code so it would react to currency changes made by the user.
It took me a while to get this to work, but eventually I used this line to include the WPML logic into my script:
do_action('wpml_before_init');

This enabled me to use code to get the product prices in the currency selected by the user:
// Product Price
//Conversion
$regular_price = apply_filters('wcml_raw_price_amount', $product->get_regular_price());
$sale_price = apply_filters('wcml_raw_price_amount', $product->get_sale_price());
// Retrieve the current currency
$currency = isset($woocommerce_wpml->multi_currency) ? $woocommerce_wpml->multi_currency->get_client_currency() : get_woocommerce_currency();
// Format prices based on the current currency, ensuring currency code is included
$formatted_regular_price = wc_price($regular_price, array('currency' => $currency));
$formatted_sale_price = wc_price($sale_price, array('currency' => $currency));

Before I activated the plugins needed for the translation part of WPML to be usable I had to include the WPML logic with do_action('wpml_before_init');

After activating both plugins:
- WPML Multilingual CMS
- WPML String Translation

The inclusion of do_action('wpml_before_init'); caused some logic to be included twice, so my website generated a Critical error until I would deactivate one of the two plugins mentioned above.

I hope this will help other people in the future, but above all, I think the plugin developers can use this information to make some changes to the plugin code, preventing this from happening in the future.
I think there can be a relatively simple solution to make sure that this situation won't occur for other users in the future.

I look forward to work with the translation functionality you provide.

One last thing.. The plugin used up a lot of my translation credits in the time it wasn't working properly.
So now I have lost more than half of the credits dispite it hasn't been able to save the translations properly on my website.
Is there any way I can get compensated for the loss in translation credits?

I wrote a detailed error report and solution, so I hope that in turn you can help me by refunding the credits lost during this process.

May 8, 2024 at 9:25 pm #15607903

nickG-26

Translations previously executed are not working at all.
Most pages have accurate translations available, but are not appended to the page for some reason,
Some pages don't have complete translations, and even the translations available are not appended to the page on language swtich.
And some pages don't have translations at all, dispite of the plugin saying that the page has been translated...

I would like to start over completely fresh, it looks really messy right now and nothing is working properly.

Can you please refund me the credits used so I can use the plugin again to make proper translations and could you please tell me how I can reset everything so the plugin can start over fresh?

May 8, 2024 at 9:31 pm #15607906

nickG-26

Before you ask, the translations ARE published.
I selected the option to publish all translations and also mark them for review.

Dispite being published, the only part of my website being translated is the menu in my header.

Like i mentiond above, I would like to have a refund in translation credits so I can start over fresh.

May 9, 2024 at 7:04 am #15608819

Laura
WPML Supporter since 05/2018

Languages: English (English ) Italian (Italiano )

Timezone: Europe/Rome (GMT+02:00)

Hi,

I will take care of your issue from now on.

First of all, thanks for the rport of the issue. I'll forward it to our devs and we'll see if it's possibile to add some code to prevent it happening again.

Now, about the translations. When you use automatic translations, all translations are saved in our external server with a "translation memory". Therefore, your credits are not wasted, it's just a matter to retrieve the translation correctly.

I can see from your plugins list you're not using String Translation. This is needed for Elementor and other plugins you're using, so it might be the reason why you can't see your translations.
Can you please install it from Plugin > Add new > Commercial and send everything to translation again?

May 9, 2024 at 7:43 am #15609041

nickG-26

The plugin list I provided in my first post was the situation where my site kept crashing when I installed and activated the string translation plugin, so that's the reasin why it wasn't on the list. In the current situation I have installed this plugin together with the wpml multilanguage cms. I can see the translations on most of the pages when i look under WPML->string translations, but when I go to the actual page on my website and switch to anothe language, the only thing that's being translated is my header menu.

May 9, 2024 at 8:05 am #15609139

Laura
WPML Supporter since 05/2018

Languages: English (English ) Italian (Italiano )

Timezone: Europe/Rome (GMT+02:00)

In any case, if you want to try a "fresh start", you can do a WPML Reset following these steps.

As I said, translations are present in our server, so no extra credits should be consumed, unless something else is translated.

If you keep having issues retriving the translations, I'll be happy to continue debugging.

May 9, 2024 at 4:09 pm #15611538

nickG-26

I tried following these steps, but at step 1 I already get different results than expected.
Please look at the image to see what the problem is.

It won't delete everything from the languages.
Tried multiple times but no success.
My browser console generates some errors after a little while, errors are the same for each language when i try to delete them:
Uncaught (in promise) SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
n hidden link
l hidden link
(Async: promise callback)
n hidden link
u hidden link
exports hidden link
exports hidden link
j hidden link
Z hidden link
u hidden link
p hidden link
y hidden link
y hidden link
it hidden link
at hidden link
ut hidden link
pt hidden link
L hidden link
V hidden link
Jt hidden link
Xt hidden link
unstable_runWithPriority hidden link
$a hidden link
I hidden link
Yt hidden link

Should I proceed to step 2 regardless?

Screenshot 2024-05-09 180611.png
May 9, 2024 at 4:13 pm #15611590

nickG-26

I was running it in firefox from my desktop.
When I try it in microsoft edge i get this error:
Uncaught (in promise) SyntaxError: Unexpected token '<', "<h4>
Are "... is not valid JSON

When I click the option to show the code that's generating the error I get this:

<h4>
Are you sure you want to delete your Site Settings?</h4>

<p>
By removing this template you will delete your entire Site Settings. If this template is deleted, all associated settings: Global Colors & Fonts, Theme Style, Layout, Background, and Lightbox settings will be removed from your existing site. This action can not be undone.</p>

<br/>

hidden link">
Delete


Keep my settings

<style>
/* In WordPress "die" screen there is very basic style, so the current css is required for basic button styles. */
.btn {
text-decoration: none;
padding: 9px 20px;
font-weight: 500;
border-radius: 3px;
}

.btn-danger {
display: inline-block;
color: #a00;
}

.btn-danger:hover, .btn-danger:focus, .btn-danger:active {
color: #dc3232;
}

.btn-primary {
color: #fff;
background-color: #007cba;
margin: 0 10px;
}

.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
background-color: #0071a1;
color: #fff;
}
</style>

Where the error is originating from the first line "<h4>"

May 9, 2024 at 4:20 pm #15611598

nickG-26

I see that all html tags and such get removed from the comment text, and only plain text remains.

The error occurs on a h4 element on top of the snippet.
It looks like it is the html used to show the modal that pops up when you click the delete button with the cross inside, right of the language you want to delete.
When i click the "Yes, delete all "language_name" translations" button, the error comes up after some seconds..

May 9, 2024 at 4:22 pm #15611599

nickG-26

I'm sorry for the spamming, but wouldn't it be better if I would make a temporary admin account on my wordpress site and share the login details with you?
Is there any way I can PM you privatly?

May 9, 2024 at 5:05 pm #15611693

Laura
WPML Supporter since 05/2018

Languages: English (English ) Italian (Italiano )

Timezone: Europe/Rome (GMT+02:00)

I can activate a private box for credentials and take a look, but it would be better if you had a staging site.

The devs told me they'd need more details about the initial issue and possibily even a copy of the site for further debugging.

May 10, 2024 at 9:13 am #15613593

Laura
WPML Supporter since 05/2018

Languages: English (English ) Italian (Italiano )

Timezone: Europe/Rome (GMT+02:00)

No it's normal to get that message and it's only relative to the Translation Editor, it won't impact our debugging.

The topic ‘[Closed] Fatal error when using WPML Multilingual CMS & WPML String Translation combined’ is closed to new replies.