Outil de recherche WordPress pour les développeurs et auteurs de thèmes



_n ›

Depuis2.8.0
Dépréciéen/a
_n ( $single, $plural, $number, $domain = 'default' )
Paramètres: (4)
  • (string) $single The text to be used if the number is singular.
    Requis: Oui
  • (string) $plural The text to be used if the number is plural.
    Requis: Oui
  • (int) $number The number to compare against to use either the singular or plural form.
    Requis: Oui
  • (string) $domain Optional. Text domain. Unique identifier for retrieving translated strings. Default 'default'.
    Requis: Non
    Défaut: 'default'
Retourne:
  • (string) The translated singular or plural form.
Défini(e) dans:
Codex:

Translates and retrieves the singular or plural form based on the supplied number.

Used when you want to use the appropriate form of a string based on whether a number is singular or plural.

Example:

printf( _n( '%s person', '%s people', $count, 'text-domain' ), number_format_i18n( $count ) );


Fonctions en relation: _nc, _nx, _, _x, _e

Source

function _n( $single, $plural, $number, $domain = 'default' ) {
	$translations = get_translations_for_domain( $domain );
	$translation  = $translations->translate_plural( $single, $plural, $number );

	/**
	 * Filters the singular or plural form of a string.
	 *
	 * @since 2.2.0
	 *
	 * @param string $translation Translated text.
	 * @param string $single      The text to be used if the number is singular.
	 * @param string $plural      The text to be used if the number is plural.
	 * @param string $number      The number to compare against to use either the singular or plural form.
	 * @param string $domain      Text domain. Unique identifier for retrieving translated strings.
	 */
	return apply_filters( 'ngettext', $translation, $single, $plural, $number, $domain );
}