When to use wp_set_script_translations?
-
Hi,
For custom JS files we enqueue we usually include
const { __, _x, _n, _nx } = wp.i18n;
and add in translatable strings in the JS.We’ve since found the
wp_set_script_translations
function but there isn’t much information around on when it should be used, we only came across the use of this while looking at some example code for server side implementation of a WooCommerce Checkout block payment method, and most information online usingwp_set_script_translations
seems to be coming from block related functionality, rather than enqueuing of non-block based JS.Should this function be used when you have a JS file that enqueues
wp-i18n
and usesconst { __, _x, _n, _nx } = wp.i18n;
?
- The topic ‘When to use wp_set_script_translations?’ is closed to new replies.