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.

This topic contains 1 reply, has 2 voices.

Last updated by Mohamed Sayed 1 year, 2 months ago.

Assisted by: Mohamed Sayed.

Author Posts
September 22, 2023 at 2:45 pm #14447575

Atiq Rahman

Tell us what you are trying to do?

have some text from browser like below

if (!buttonText) {
buttonText = "Switch to AI Website";
localStorage.setItem("buttonText", buttonText);
}

How can i translate them?

It javascriptcode
thank you

September 24, 2023 at 11:56 am #14452413

Mohamed Sayed

Hi there,
Thanks for contacting WPML support.

By default, Javascript strings are not translatable unless they have been localized. Please check the following guides for more details:

https://developer.wordpress.org/reference/functions/wp_localize_script/

https://wpml.org/documentation/support/enabling-text-translation-for-themes-not-compatible-with-wpml/

Unfortunately, translating text added with Javascript is considered custom work which is currently outside the scope of our support.

If you are still experiencing an issue localizing this javascript we suggest contacting one of our 3rd party contractors that specialize in custom work with WPML https://wpml.org/contractors/

Kind regards,
Mohamed