Last active
October 22, 2015 14:49
-
-
Save ihorvorotnov/7c79a15e95275ca2a6c5 to your computer and use it in GitHub Desktop.
Complex translation strings in WordPress themes and plugins
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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