Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
Register strings for translation and output them on the frontend.
Solution:
https://wpml.org/documentation/support/enabling-text-translation-for-themes-not-compatible-with-wpml/

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.

Our next available supporter will start replying to tickets in about 5.33 hours from now. Thank you for your understanding.

This topic contains 4 replies, has 3 voices.

Last updated by jeppeS-3 1 year, 8 months ago.

Assisted by: Long Nguyen.

Author Posts
February 22, 2023 at 1:16 pm #13089345

jeppeS-3

Tell us what you are trying to do?
I am trying to translate a piece of text. That possibly may be "hardcoded" into the HTML.
I am unsure how to translate this. And if it is even possible with WPML.
If it is not possible, then a suggestion to what route i then might take - possibly translating it manually using functions.php?

Is there any documentation that you are following?
No, i can't find any.

Is there a similar example that we can see?
This is the text i am trying to translate: hidden link
And it looks like in the Chrome Dev Tool, that it indeed is some sort of "hardcoded": hidden link

What is the link to your site?
You can see it on a mobile phone on this URL: hidden link
The text i am trying to translate is "Vis undermenu" and "Skjul undermenu". Which is respectively "Show submenu" and "Hide submenu" in english.

February 22, 2023 at 1:55 pm #13089757

Dražen Duvnjak
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+01:00)

Hello,

if the text is hard coded in your theme files, you will need to make sure you are using recommended approach and wrapping text in the get text domain, to be translatable.

Then scan your theme files and translate via WPML String translation.

Please check the next docs for further info:

- https://wpml.org/documentation/support/enabling-text-translation-for-themes-not-compatible-with-wpml/
- https://wpml.org/documentation/getting-started-guide/string-translation/finding-strings-that-dont-appear-on-the-string-translation-page/#strings-arent-selected-for-translation

Kind regards,
Drazen

March 3, 2023 at 8:09 am #13161153

jeppeS-3

I tried editing the theme files with the guide you sent. But it just shows up empty on the website.

Source code after editing: hidden link
And also see: hidden link
This is the page from the screenshot, if you can use that for anything: hidden link

My edits to the template file (which may possibly be wrong): hidden link

I get the strings to translate in the string translation, and translate them, but still it is empty when visiting the website.

March 3, 2023 at 9:12 am #13161693

Long Nguyen
Supporter

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi there,

Thank you for contacting WPML support, I'd be happy to help you with this issue.

You should add echo to output the string on the frontend like this

<?php echo __('this is a some message', 'my-plugin-domain'); ?>

While checking the debug info, I see that the WordPress Memory Limit is below the requirements. The minimum requirements are 128M, but we do recommend 256M and the debug information of your site shows it set to 40M. Please check this link for more details
https://wpml.org/home/minimum-requirements/.
You can increase it by adding the following code in your wp-config.php file, right before the /* That’s all, stop editing! Happy publishing. */ line:


define( 'WP_MAX_MEMORY_LIMIT', '256M' );
define( 'WP_MEMORY_LIMIT', '128M' );

After adding the code you can confirm that the memory was changed correctly from WPML > Support > WordPress > Memory limit.

Look forward to your reply.
Thanks