Skip to content Skip to sidebar

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

Problem:
You want to translate the JavaScript and PHP files on your website.
Solution:
To make text in these files translatable, you need to register the strings with WordPress' localization functions. Here's how:

For PHP files:
Wrap any user-facing text in WordPress i18n functions such as

__()

or

_e()

with your theme or plugin text domain. For example:

echo __( 'Your text here', 'theme-textdomain' );

For JavaScript files:
Text hardcoded in JavaScript files cannot be translated automatically. Instead, pass strings from PHP to JavaScript using functions like

wp_localize_script()

or

wp_set_script_translations()

. For example:

wp_localize_script( 'my-script', 'myStrings', [ 'welcome' => __( 'Welcome message', 'theme-textdomain' ) ]);

After registering, you can find these strings in WPML → String Translation, where you can provide translations for each language.

If you need further assistance or if this solution does not apply to your 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.

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.

Tagged: 

This topic contains 4 replies, has 0 voices.

Last updated by Andreas W. 3 weeks, 4 days ago.

Assisted by: Andreas W..

Author Posts
January 3, 2026 at 9:53 pm #17701699

İrfan Kaya

I want to translate the JavaScript and PHP files on my website. Could you explain how to do this?

January 4, 2026 at 1:35 am #17701773

Andreas W.
WPML Supporter since 12/2018

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

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

Hello,

Thank you for your question.

WPML does not translate raw JavaScript or PHP files directly. To make text inside those files translatable, the strings need to be registered with WordPress’ localization functions so WPML can detect them.

PHP files:
Wrap any user‑facing text in WordPress i18n functions such as __() or _e() with your theme/plugin text domain. Example:

echo __( 'Your text here', 'theme-textdomain' );

WPML will then expose these strings in String Translation.

JavaScript files:
Hardcoded text in JS cannot yet be translated automatically. Instead, pass strings from PHP into JS using wp_localize_script() or wp_set_script_translations(). Example:

wp_localize_script( 'my-script', 'myStrings', [
  'welcome' => __( 'Welcome message', 'theme-textdomain' ),
]);

The PHP string is registered for translation, and WPML injects the translated value into your JS.

Once registered, you’ll find these strings in WPML → String Translation, where you can provide translations for each language.

If you could share a specific example of the text you want to translate (a snippet from your PHP or JS), we can guide you on how to wrap it correctly so WPML can handle it.

Source:
WordPress Internationalization Guidelines

The wp_localize_script function

Best regards
Andreas

January 4, 2026 at 8:47 am #17701928

İrfan Kaya

Hello, unfortunately, as a beginner, even though WPML is very good, it doesn't seem to be doing the job for me. I wanted my site to be multilingual like forebet.com, but there are thousands of pieces of content created with PHP and JavaScript files. It's impossible for me to do all of that. Could you review my site and suggest a solution? Also, the fact that the plugin doesn't support Turkish is making my job quite difficult. (My site: sportanaliz.com)

January 6, 2026 at 9:55 am #17706092

Andreas W.
WPML Supporter since 12/2018

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

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

Hello,

I'd be happy to take a closer look at this and request temporary access (wp-admin and FTP) to the website to investigate the issue further.

You'll find the necessary fields below the comment section if you log in to leave the next reply. The information you provide will be private, meaning only you and I will be able to see and access it.

IMPORTANT
Please be sure to create a backup of the website and database before granting us access.

If you don't see the "wp-admin / FTP" fields, your login credentials for the post and website will be set to "PUBLIC." Do NOT publish the information unless you see the required wp-admin / FTP fields.

The private reply form looks like this:

hidden link

When replying again, click "I still need assistance".

Video:
hidden link

Please note that we are required to request this information individually on each ticket. We are not permitted to access any login information that was not specifically provided in the private reply form for this ticket.

Best regards,
Andreas

January 17, 2026 at 9:08 pm #17739498

Andreas W.
WPML Supporter since 12/2018

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

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

Hello,

I did not hear back from you, and I wanted to know if you still need assistance.

In case you still need assistance, it would be very helpful if you could send us the WPML troubleshooting information.

More information can be found here:
https://wpml.org/de/faq/provide-debug-information-faster-support/

---

You said:
"Also, the fact that the plugin doesn't support Turkish is making my job quite difficult."

WPML does support Turkish as a pre-installed language and for automatic translation:
https://wpml.org/documentation/getting-started-guide/language-setup/pre-configured-languages/

Language pairs for the PTC translation engine:
hidden link

More about automatic translations:
https://wpml.org/documentation/automatic-translation/

The reason for not seeing Turkish on an untranslated website would be based on the fact that the used theme or other plugins do not come with Turkish language files or the site is not set up correctly.

I can offer to take a look into this for you.

Note that content from pages and posts will be translated with the WPML Translation Editor, which also allows automatic translations. These translations also include assigned media files, custom fields, and taxonomies for each post or page.

Other strings, which come from themes or plugins, can be translated at WPML > String Translation.

Let me know if you need further assistance, or simply mark this ticket as closed or resolved.

Best regards
Andreas