Skip to content

Instantly share code, notes, and snippets.

@nielslange
Last active November 8, 2021 13:18
Show Gist options
  • Save nielslange/f64a3f5fdd3102ef3c2ab78cc7d899c9 to your computer and use it in GitHub Desktop.
Save nielslange/f64a3f5fdd3102ef3c2ab78cc7d899c9 to your computer and use it in GitHub Desktop.
Translating strings
import { __ } from '@wordpress/i18n';
__( 'Hello, Luigi!', 'woo-gutenberg-products-block' );
import { __, sprintf } from '@wordpress/i18n';
const name = 'Luigi';
sprintf(
__( 'Hello, %s!', 'woo-gutenberg-products-block' ),
name
);
import { _n, sprintf } from '@wordpress/i18n';
const quantity = 5;
sprintf(
/* translators: %d number of products of the same type in the cart */
_n(
'%d item',
'%d items',
quantity,
'woo-gutenberg-products-block'
),
quantity
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment