wpseek.com
Bazujące na WordPress narzędzie wyszukiwania dla deweloperów i twórców motywów.



_n › WordPress Function

Od2.8.0
Przestarzałyn/a
_n ( $single, $plural, $number, $domain = 'default' )
Parametry: (4)
  • (string) $single The text to be used if the number is singular.
    Wymagane: Tak
  • (string) $plural The text to be used if the number is plural.
    Wymagane: Tak
  • (int) $number The number to compare against to use either the singular or plural form.
    Wymagane: Tak
  • (string) $domain Optional. Text domain. Unique identifier for retrieving translated strings. Default 'default'.
    Wymagane: Nie
    Domyślny: 'default'
Powrót:
  • (string) The translated singular or plural form.
Zdefiniowane na:
Codex:
Dziennik zmian:
  • 5.5.0

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 ) );


Powiązane Funkcje: _nc, _nx, _, __, _c

Źródło

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 int    $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.
	 */
	$translation = apply_filters( 'ngettext', $translation, $single, $plural, $number, $domain );

	/**
	 * Filters the singular or plural form of a string for a domain.
	 *
	 * The dynamic portion of the hook name, `$domain`, refers to the text domain.
	 *
	 * @since 5.5.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 int    $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.
	 */
	$translation = apply_filters( "ngettext_{$domain}", $translation, $single, $plural, $number, $domain );

	return $translation;
}