Support » Plugin: Polylang » Call pll_e function from JavaScript

  • Resolved Igor Lopasovsky


    Hey Guys,

    Is it somehow possible to call pll_e function from JavaScript? I generate HTML content dynamically from JS and I need it to be translated.

    Many thanks for help.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The Coder


    pll_e is a PHP function and it runs on the server. PHP generates the final HTML code. JavaScript is embedded in HTML and it runs on the client, so it can not call a PHP function. If you want to do so, you have to use ajax to request a PHP result.

    Plugin Author Chouby



    This is the function used by WP to send translated strings from PHP to js:

    You can use pll__() instead of __() to do the same with strings translated by Polylang.

    Igor Lopasovsky


    Thank you very much for help. This is exactly what I was looking for.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Call pll_e function from JavaScript’ is closed to new replies.