Skip to content

Instantly share code, notes, and snippets.

@ihorvorotnov
Last active October 22, 2015 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ihorvorotnov/7c79a15e95275ca2a6c5 to your computer and use it in GitHub Desktop.
Save ihorvorotnov/7c79a15e95275ca2a6c5 to your computer and use it in GitHub Desktop.
Complex translation strings in WordPress themes and plugins
<?php
/**
* The following is the proper way to handle complex translation strings.
* By Justin Tadlock
* @see https://wpchat.com/t/do-you-use-format-placeholders-s-and-d-in-translatable-strings/1138/11
*/
$number = get_donation_count();
$string = sprintf(
// translators: %s is the number of donations.
_n( 'You have %s donation.', 'You have %s donations', $number, 'my-domain' ),
"<span>{$number}</span>"
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment