Home›Support›English Support›[Resolved] Translation Management > Other texts (Strings) Stuck with message "Loading items..."
[Resolved] Translation Management > Other texts (Strings) Stuck with message "Loading items..."
This thread is resolved. Here is a description of the problem and solution.
Problem: The client is experiencing an issue where the 'Other texts (Strings)' section in WPML > Translation Management does not load strings and continuously displays 'Loading items...'. This is due to PHP Warnings being returned instead of valid JSON from the endpoint. The warnings are caused by undefined array keys in the PHP code handling the data. Solution: We discovered that switching the theme resolved the issue, indicating that the problem was related to the custom theme used. Additionally, deleting the strings in WPML > String Translation that were waiting for a translator resolved the issue. We recommend checking if any custom theme or plugin might be overriding PHP error settings and causing warnings to display. If the problem persists, consider deleting strings waiting for translation in WPML > String Translation.
Please note that this solution might be outdated or not applicable to your specific 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 the issue persists, please open a new support ticket at WPML support forum.
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.
Background of the issue:
I am trying to load strings in the Translation Management > Other texts (Strings) section after moving our site to new hosting. The section fetches JSON from the endpoint "/wp-json/wpml/st/v1/strings?offset=0&limit=76&sourceLanguageCode=en". The endpoint code is displaying PHP Warnings instead of returning JSON. Here is the code causing the issue:
<code>
return array_map(
function( $row ) {
$getIntOrNull = function( $row, $key ) {
return is_numeric( $row[ $key ] ) ? (int) $row[ $key ] : null;
};
$getStringOrNull = function( $row, $key ) {
return is_string( $row[ $key ] ) && strlen( $row[ $key ] ) > 0
? $row[ $key ]
: null;
};
return new TranslationDetailsDto(
$row['language_code'],
(int) $row['translation_id'],
(int) $row['string_id'],
$getIntOrNull( $row, 'rid' ),
$getIntOrNull( $row, 'job_id' ),
$getIntOrNull( $row, 'automatic' ),
$getStringOrNull( $row, 'editor' ),
$getStringOrNull( $row, 'translation_service' ),
$getStringOrNull( $row, 'review_status' ),
$getIntOrNull( $row, 'translator_id' )
);
},
$res
);
</code>
A simple solution would be that in the $getIntOrNull and $getStringOrNull functions, if you add a conditional statement that checks <code> if( array_key_exists($row[ $key ]) ... else null; </code> then the code won’t throw off Warnings.
Symptoms:
The Other texts (Strings) section won't load strings and keeps displaying the message "Loading items...". The endpoint is returning PHP Warnings instead of valid JSON. The error being returned is: <code> <br /> <b>Warning</b>: Undefined array key "job_id" in <b>/usr/www/users/stage/***hidden***/public_html/wp-content/plugins/wpml-string-translation/StringTranslation/Infrastructure/Translation/Query/FindTranslationDetailsQuery.php</b> on line <b>73</b><br /> </code>
I know that the simple solution is to disable PHP Warnings and I had done this and tested that it's working correctly. For some reason, on my new hosting it's still displaying these PHP Warnings. My guess is that one of my plugins is setting display PHP Warnings to true and this new hosting is respecting that where the old hosting was ignoring it.
Questions:
Can you make this simple modification to your code to stop the script from throwing off PHP Warnings. It would seem logical to ensure array keys exist before referencing them.
Languages: English (English )Spanish (Español )German (Deutsch )
Timezone: America/Lima (GMT-05:00)
Hello,
I can sadly not simply suggest a code change to the devs unless I know what has been causing the issue.
In this case, it kind of looks like an issue about a translation job for strings, but we also had similar cases in the past, where, for example, a placeholder was not translated correctly and this is causing an error.
I would like to request temporary access (wp-admin and FTP) to the website to investigate the issue further.
You can find the required fields below the comments section when you log in to leave the next reply. The information you provide is private, meaning only you and I can see and access it.
IMPORTANT
Please be sure to back up your website and database before granting us access.
If you can't see the "wp-admin / FTP" fields, your post and website credentials will be set to "PUBLIC." DO NOT publish the data unless you see the required wp-admin / FTP fields.
I may need to install a plugin called "All In One WP Migration" to create a copy of the website so I can investigate the issue further.
However, I would also be very grateful if you could provide a staging site or a copy of the website from your server for this purpose.
If you have any questions about creating such a staging site, you can consult your hosting provider. Please note that WPML must also be registered on this staging site at https://wpml.org/account/websites/.
If you are unable to provide such a copy of the website for testing, please let me know on this ticket.
The private reply form looks like this: hidden link
Click "I still need assistance" the next time you reply.
Video: hidden link
Please note that we are required to request this information individually on each ticket. We are not permitted to access any credentials that were not specifically submitted on this ticket using the private response form.
Languages: English (English )Spanish (Español )German (Deutsch )
Timezone: America/Lima (GMT-05:00)
The issue at WPML > Translation Management > Dashboard > Other texts disappears once I switch the theme.
This means that some code inside this custom theme is causing the issue.
Also, I see that there seem to be strings from the theme waiting for a translation job to be completed, but if I check the Translation Management, I do not see such a job.
I would suggest trying to delete the strings that are waiting for a translator to complete the translation, at WPML > String Translation.
Do you mind if we test this on the staging site first?
Please proceed with the test. Thank you. When you say "This means that some code inside this custom theme is causing the issue.", do you mean the theme is referencing a string that has no "job_id". When the theme changes, that string is no longer being used an so the Other texts works again?