Support » Developing with WordPress » How to load Javascript translation through Ajax request

  • Hi,

    I want to load how can I load JS translation through Ajax request. I am using REST API to fetch post with ajax, and I have manually added load_theme_textdomain() to the request to fetch PHP translation.

    I tried to do the same to fetch Javascript translation, but it doesn’t work. Is this possible?

    My current code:

    function ajax_load_script_textdomain(){
        load_script_textdomain('CUSTOM-block-ref-holder', 'custom-blocks', plugin_dir_path(__FILE__) . 'languages');
    add_action('init', 'ajax_load_script_textdomain');
    add_action('rest_api_init', 'ajax_load_script_textdomain');
Viewing 1 replies (of 1 total)
  • Moderator bcworkz


    The translation scheme in WP using text domains doesn’t translate post content, it only translates UI elements. If you want post content in multiple languages you need a multilingual plugin.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.