Autonomía digital y tecnológica

Código e ideas para una internet distribuida

Linkoteca. traducción de cadenas


You need to “tell” WP that your script has a translation, and specify which text domain (ID) should be used for this translation. This is done using the wp_set_script_translations() function.

So, the registration of your script with translation should look like this:

wp_register_script( ‘my-handle’, plugins_url( ‘/js/my-file.js’, __FILE__ ) );
wp_set_script_translations( ‘my-handle’, ‘my-domain’ );

The wp_set_script_translations() function adds a dependency on the main script for wp-i18n and includes the .json file.

A built-in feature of Next.js Internationalization enables you to develop a website with content in various languages. The routing and rendering of several language versions of your website are handled automatically by Next.js. The user’s preferred language can be determined using Next.js, which can then offer the appropriate content.