Edit File by line
/home/zeestwma/richards.../wp-inclu...
File: l10n.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Core Translation API
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
* @subpackage i18n
[5] Fix | Delete
* @since 1.2.0
[6] Fix | Delete
*/
[7] Fix | Delete
[8] Fix | Delete
/**
[9] Fix | Delete
* Retrieves the current locale.
[10] Fix | Delete
*
[11] Fix | Delete
* If the locale is set, then it will filter the locale in the {@see 'locale'}
[12] Fix | Delete
* filter hook and return the value.
[13] Fix | Delete
*
[14] Fix | Delete
* If the locale is not set already, then the WPLANG constant is used if it is
[15] Fix | Delete
* defined. Then it is filtered through the {@see 'locale'} filter hook and
[16] Fix | Delete
* the value for the locale global set and the locale is returned.
[17] Fix | Delete
*
[18] Fix | Delete
* The process to get the locale should only be done once, but the locale will
[19] Fix | Delete
* always be filtered using the {@see 'locale'} hook.
[20] Fix | Delete
*
[21] Fix | Delete
* @since 1.5.0
[22] Fix | Delete
*
[23] Fix | Delete
* @global string $locale The current locale.
[24] Fix | Delete
* @global string $wp_local_package Locale code of the package.
[25] Fix | Delete
*
[26] Fix | Delete
* @return string The locale of the blog or from the {@see 'locale'} hook.
[27] Fix | Delete
*/
[28] Fix | Delete
function get_locale() {
[29] Fix | Delete
global $locale, $wp_local_package;
[30] Fix | Delete
[31] Fix | Delete
if ( isset( $locale ) ) {
[32] Fix | Delete
/** This filter is documented in wp-includes/l10n.php */
[33] Fix | Delete
return apply_filters( 'locale', $locale );
[34] Fix | Delete
}
[35] Fix | Delete
[36] Fix | Delete
if ( isset( $wp_local_package ) ) {
[37] Fix | Delete
$locale = $wp_local_package;
[38] Fix | Delete
}
[39] Fix | Delete
[40] Fix | Delete
// WPLANG was defined in wp-config.
[41] Fix | Delete
if ( defined( 'WPLANG' ) ) {
[42] Fix | Delete
$locale = WPLANG;
[43] Fix | Delete
}
[44] Fix | Delete
[45] Fix | Delete
// If multisite, check options.
[46] Fix | Delete
if ( is_multisite() ) {
[47] Fix | Delete
// Don't check blog option when installing.
[48] Fix | Delete
if ( wp_installing() ) {
[49] Fix | Delete
$ms_locale = get_site_option( 'WPLANG' );
[50] Fix | Delete
} else {
[51] Fix | Delete
$ms_locale = get_option( 'WPLANG' );
[52] Fix | Delete
if ( false === $ms_locale ) {
[53] Fix | Delete
$ms_locale = get_site_option( 'WPLANG' );
[54] Fix | Delete
}
[55] Fix | Delete
}
[56] Fix | Delete
[57] Fix | Delete
if ( false !== $ms_locale ) {
[58] Fix | Delete
$locale = $ms_locale;
[59] Fix | Delete
}
[60] Fix | Delete
} else {
[61] Fix | Delete
$db_locale = get_option( 'WPLANG' );
[62] Fix | Delete
if ( false !== $db_locale ) {
[63] Fix | Delete
$locale = $db_locale;
[64] Fix | Delete
}
[65] Fix | Delete
}
[66] Fix | Delete
[67] Fix | Delete
if ( empty( $locale ) ) {
[68] Fix | Delete
$locale = 'en_US';
[69] Fix | Delete
}
[70] Fix | Delete
[71] Fix | Delete
/**
[72] Fix | Delete
* Filters the locale ID of the WordPress installation.
[73] Fix | Delete
*
[74] Fix | Delete
* @since 1.5.0
[75] Fix | Delete
*
[76] Fix | Delete
* @param string $locale The locale ID.
[77] Fix | Delete
*/
[78] Fix | Delete
return apply_filters( 'locale', $locale );
[79] Fix | Delete
}
[80] Fix | Delete
[81] Fix | Delete
/**
[82] Fix | Delete
* Retrieves the locale of a user.
[83] Fix | Delete
*
[84] Fix | Delete
* If the user has a locale set to a non-empty string then it will be
[85] Fix | Delete
* returned. Otherwise it returns the locale of get_locale().
[86] Fix | Delete
*
[87] Fix | Delete
* @since 4.7.0
[88] Fix | Delete
*
[89] Fix | Delete
* @param int|WP_User $user User's ID or a WP_User object. Defaults to current user.
[90] Fix | Delete
* @return string The locale of the user.
[91] Fix | Delete
*/
[92] Fix | Delete
function get_user_locale( $user = 0 ) {
[93] Fix | Delete
$user_object = false;
[94] Fix | Delete
[95] Fix | Delete
if ( 0 === $user && function_exists( 'wp_get_current_user' ) ) {
[96] Fix | Delete
$user_object = wp_get_current_user();
[97] Fix | Delete
} elseif ( $user instanceof WP_User ) {
[98] Fix | Delete
$user_object = $user;
[99] Fix | Delete
} elseif ( $user && is_numeric( $user ) ) {
[100] Fix | Delete
$user_object = get_user_by( 'id', $user );
[101] Fix | Delete
}
[102] Fix | Delete
[103] Fix | Delete
if ( ! $user_object ) {
[104] Fix | Delete
return get_locale();
[105] Fix | Delete
}
[106] Fix | Delete
[107] Fix | Delete
$locale = $user_object->locale;
[108] Fix | Delete
[109] Fix | Delete
return $locale ? $locale : get_locale();
[110] Fix | Delete
}
[111] Fix | Delete
[112] Fix | Delete
/**
[113] Fix | Delete
* Determines the current locale desired for the request.
[114] Fix | Delete
*
[115] Fix | Delete
* @since 5.0.0
[116] Fix | Delete
*
[117] Fix | Delete
* @global string $pagenow The filename of the current screen.
[118] Fix | Delete
*
[119] Fix | Delete
* @return string The determined locale.
[120] Fix | Delete
*/
[121] Fix | Delete
function determine_locale() {
[122] Fix | Delete
/**
[123] Fix | Delete
* Filters the locale for the current request prior to the default determination process.
[124] Fix | Delete
*
[125] Fix | Delete
* Using this filter allows to override the default logic, effectively short-circuiting the function.
[126] Fix | Delete
*
[127] Fix | Delete
* @since 5.0.0
[128] Fix | Delete
*
[129] Fix | Delete
* @param string|null $locale The locale to return and short-circuit. Default null.
[130] Fix | Delete
*/
[131] Fix | Delete
$determined_locale = apply_filters( 'pre_determine_locale', null );
[132] Fix | Delete
[133] Fix | Delete
if ( $determined_locale && is_string( $determined_locale ) ) {
[134] Fix | Delete
return $determined_locale;
[135] Fix | Delete
}
[136] Fix | Delete
[137] Fix | Delete
if (
[138] Fix | Delete
isset( $GLOBALS['pagenow'] ) && 'wp-login.php' === $GLOBALS['pagenow'] &&
[139] Fix | Delete
( ! empty( $_GET['wp_lang'] ) || ! empty( $_COOKIE['wp_lang'] ) )
[140] Fix | Delete
) {
[141] Fix | Delete
if ( ! empty( $_GET['wp_lang'] ) ) {
[142] Fix | Delete
$determined_locale = sanitize_locale_name( $_GET['wp_lang'] );
[143] Fix | Delete
} else {
[144] Fix | Delete
$determined_locale = sanitize_locale_name( $_COOKIE['wp_lang'] );
[145] Fix | Delete
}
[146] Fix | Delete
} elseif (
[147] Fix | Delete
is_admin() ||
[148] Fix | Delete
( isset( $_GET['_locale'] ) && 'user' === $_GET['_locale'] && wp_is_json_request() )
[149] Fix | Delete
) {
[150] Fix | Delete
$determined_locale = get_user_locale();
[151] Fix | Delete
} elseif (
[152] Fix | Delete
( ! empty( $_REQUEST['language'] ) || isset( $GLOBALS['wp_local_package'] ) )
[153] Fix | Delete
&& wp_installing()
[154] Fix | Delete
) {
[155] Fix | Delete
if ( ! empty( $_REQUEST['language'] ) ) {
[156] Fix | Delete
$determined_locale = sanitize_locale_name( $_REQUEST['language'] );
[157] Fix | Delete
} else {
[158] Fix | Delete
$determined_locale = $GLOBALS['wp_local_package'];
[159] Fix | Delete
}
[160] Fix | Delete
}
[161] Fix | Delete
[162] Fix | Delete
if ( ! $determined_locale ) {
[163] Fix | Delete
$determined_locale = get_locale();
[164] Fix | Delete
}
[165] Fix | Delete
[166] Fix | Delete
/**
[167] Fix | Delete
* Filters the locale for the current request.
[168] Fix | Delete
*
[169] Fix | Delete
* @since 5.0.0
[170] Fix | Delete
*
[171] Fix | Delete
* @param string $determined_locale The locale.
[172] Fix | Delete
*/
[173] Fix | Delete
return apply_filters( 'determine_locale', $determined_locale );
[174] Fix | Delete
}
[175] Fix | Delete
[176] Fix | Delete
/**
[177] Fix | Delete
* Retrieves the translation of $text.
[178] Fix | Delete
*
[179] Fix | Delete
* If there is no translation, or the text domain isn't loaded, the original text is returned.
[180] Fix | Delete
*
[181] Fix | Delete
* *Note:* Don't use translate() directly, use __() or related functions.
[182] Fix | Delete
*
[183] Fix | Delete
* @since 2.2.0
[184] Fix | Delete
* @since 5.5.0 Introduced `gettext-{$domain}` filter.
[185] Fix | Delete
*
[186] Fix | Delete
* @param string $text Text to translate.
[187] Fix | Delete
* @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
[188] Fix | Delete
* Default 'default'.
[189] Fix | Delete
* @return string Translated text.
[190] Fix | Delete
*/
[191] Fix | Delete
function translate( $text, $domain = 'default' ) {
[192] Fix | Delete
$translations = get_translations_for_domain( $domain );
[193] Fix | Delete
$translation = $translations->translate( $text );
[194] Fix | Delete
[195] Fix | Delete
/**
[196] Fix | Delete
* Filters text with its translation.
[197] Fix | Delete
*
[198] Fix | Delete
* @since 2.0.11
[199] Fix | Delete
*
[200] Fix | Delete
* @param string $translation Translated text.
[201] Fix | Delete
* @param string $text Text to translate.
[202] Fix | Delete
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
[203] Fix | Delete
*/
[204] Fix | Delete
$translation = apply_filters( 'gettext', $translation, $text, $domain );
[205] Fix | Delete
[206] Fix | Delete
/**
[207] Fix | Delete
* Filters text with its translation for a domain.
[208] Fix | Delete
*
[209] Fix | Delete
* The dynamic portion of the hook name, `$domain`, refers to the text domain.
[210] Fix | Delete
*
[211] Fix | Delete
* @since 5.5.0
[212] Fix | Delete
*
[213] Fix | Delete
* @param string $translation Translated text.
[214] Fix | Delete
* @param string $text Text to translate.
[215] Fix | Delete
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
[216] Fix | Delete
*/
[217] Fix | Delete
$translation = apply_filters( "gettext_{$domain}", $translation, $text, $domain );
[218] Fix | Delete
[219] Fix | Delete
return $translation;
[220] Fix | Delete
}
[221] Fix | Delete
[222] Fix | Delete
/**
[223] Fix | Delete
* Removes last item on a pipe-delimited string.
[224] Fix | Delete
*
[225] Fix | Delete
* Meant for removing the last item in a string, such as 'Role name|User role'. The original
[226] Fix | Delete
* string will be returned if no pipe '|' characters are found in the string.
[227] Fix | Delete
*
[228] Fix | Delete
* @since 2.8.0
[229] Fix | Delete
*
[230] Fix | Delete
* @param string $text A pipe-delimited string.
[231] Fix | Delete
* @return string Either $text or everything before the last pipe.
[232] Fix | Delete
*/
[233] Fix | Delete
function before_last_bar( $text ) {
[234] Fix | Delete
$last_bar = strrpos( $text, '|' );
[235] Fix | Delete
if ( false === $last_bar ) {
[236] Fix | Delete
return $text;
[237] Fix | Delete
} else {
[238] Fix | Delete
return substr( $text, 0, $last_bar );
[239] Fix | Delete
}
[240] Fix | Delete
}
[241] Fix | Delete
[242] Fix | Delete
/**
[243] Fix | Delete
* Retrieves the translation of $text in the context defined in $context.
[244] Fix | Delete
*
[245] Fix | Delete
* If there is no translation, or the text domain isn't loaded, the original text is returned.
[246] Fix | Delete
*
[247] Fix | Delete
* *Note:* Don't use translate_with_gettext_context() directly, use _x() or related functions.
[248] Fix | Delete
*
[249] Fix | Delete
* @since 2.8.0
[250] Fix | Delete
* @since 5.5.0 Introduced `gettext_with_context-{$domain}` filter.
[251] Fix | Delete
*
[252] Fix | Delete
* @param string $text Text to translate.
[253] Fix | Delete
* @param string $context Context information for the translators.
[254] Fix | Delete
* @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
[255] Fix | Delete
* Default 'default'.
[256] Fix | Delete
* @return string Translated text on success, original text on failure.
[257] Fix | Delete
*/
[258] Fix | Delete
function translate_with_gettext_context( $text, $context, $domain = 'default' ) {
[259] Fix | Delete
$translations = get_translations_for_domain( $domain );
[260] Fix | Delete
$translation = $translations->translate( $text, $context );
[261] Fix | Delete
[262] Fix | Delete
/**
[263] Fix | Delete
* Filters text with its translation based on context information.
[264] Fix | Delete
*
[265] Fix | Delete
* @since 2.8.0
[266] Fix | Delete
*
[267] Fix | Delete
* @param string $translation Translated text.
[268] Fix | Delete
* @param string $text Text to translate.
[269] Fix | Delete
* @param string $context Context information for the translators.
[270] Fix | Delete
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
[271] Fix | Delete
*/
[272] Fix | Delete
$translation = apply_filters( 'gettext_with_context', $translation, $text, $context, $domain );
[273] Fix | Delete
[274] Fix | Delete
/**
[275] Fix | Delete
* Filters text with its translation based on context information for a domain.
[276] Fix | Delete
*
[277] Fix | Delete
* The dynamic portion of the hook name, `$domain`, refers to the text domain.
[278] Fix | Delete
*
[279] Fix | Delete
* @since 5.5.0
[280] Fix | Delete
*
[281] Fix | Delete
* @param string $translation Translated text.
[282] Fix | Delete
* @param string $text Text to translate.
[283] Fix | Delete
* @param string $context Context information for the translators.
[284] Fix | Delete
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
[285] Fix | Delete
*/
[286] Fix | Delete
$translation = apply_filters( "gettext_with_context_{$domain}", $translation, $text, $context, $domain );
[287] Fix | Delete
[288] Fix | Delete
return $translation;
[289] Fix | Delete
}
[290] Fix | Delete
[291] Fix | Delete
/**
[292] Fix | Delete
* Retrieves the translation of $text.
[293] Fix | Delete
*
[294] Fix | Delete
* If there is no translation, or the text domain isn't loaded, the original text is returned.
[295] Fix | Delete
*
[296] Fix | Delete
* @since 2.1.0
[297] Fix | Delete
*
[298] Fix | Delete
* @param string $text Text to translate.
[299] Fix | Delete
* @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
[300] Fix | Delete
* Default 'default'.
[301] Fix | Delete
* @return string Translated text.
[302] Fix | Delete
*/
[303] Fix | Delete
function __( $text, $domain = 'default' ) {
[304] Fix | Delete
return translate( $text, $domain );
[305] Fix | Delete
}
[306] Fix | Delete
[307] Fix | Delete
/**
[308] Fix | Delete
* Retrieves the translation of $text and escapes it for safe use in an attribute.
[309] Fix | Delete
*
[310] Fix | Delete
* If there is no translation, or the text domain isn't loaded, the original text is returned.
[311] Fix | Delete
*
[312] Fix | Delete
* @since 2.8.0
[313] Fix | Delete
*
[314] Fix | Delete
* @param string $text Text to translate.
[315] Fix | Delete
* @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
[316] Fix | Delete
* Default 'default'.
[317] Fix | Delete
* @return string Translated text on success, original text on failure.
[318] Fix | Delete
*/
[319] Fix | Delete
function esc_attr__( $text, $domain = 'default' ) {
[320] Fix | Delete
return esc_attr( translate( $text, $domain ) );
[321] Fix | Delete
}
[322] Fix | Delete
[323] Fix | Delete
/**
[324] Fix | Delete
* Retrieves the translation of $text and escapes it for safe use in HTML output.
[325] Fix | Delete
*
[326] Fix | Delete
* If there is no translation, or the text domain isn't loaded, the original text
[327] Fix | Delete
* is escaped and returned.
[328] Fix | Delete
*
[329] Fix | Delete
* @since 2.8.0
[330] Fix | Delete
*
[331] Fix | Delete
* @param string $text Text to translate.
[332] Fix | Delete
* @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
[333] Fix | Delete
* Default 'default'.
[334] Fix | Delete
* @return string Translated text.
[335] Fix | Delete
*/
[336] Fix | Delete
function esc_html__( $text, $domain = 'default' ) {
[337] Fix | Delete
return esc_html( translate( $text, $domain ) );
[338] Fix | Delete
}
[339] Fix | Delete
[340] Fix | Delete
/**
[341] Fix | Delete
* Displays translated text.
[342] Fix | Delete
*
[343] Fix | Delete
* @since 1.2.0
[344] Fix | Delete
*
[345] Fix | Delete
* @param string $text Text to translate.
[346] Fix | Delete
* @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
[347] Fix | Delete
* Default 'default'.
[348] Fix | Delete
*/
[349] Fix | Delete
function _e( $text, $domain = 'default' ) {
[350] Fix | Delete
echo translate( $text, $domain );
[351] Fix | Delete
}
[352] Fix | Delete
[353] Fix | Delete
/**
[354] Fix | Delete
* Displays translated text that has been escaped for safe use in an attribute.
[355] Fix | Delete
*
[356] Fix | Delete
* Encodes `< > & " '` (less than, greater than, ampersand, double quote, single quote).
[357] Fix | Delete
* Will never double encode entities.
[358] Fix | Delete
*
[359] Fix | Delete
* If you need the value for use in PHP, use esc_attr__().
[360] Fix | Delete
*
[361] Fix | Delete
* @since 2.8.0
[362] Fix | Delete
*
[363] Fix | Delete
* @param string $text Text to translate.
[364] Fix | Delete
* @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
[365] Fix | Delete
* Default 'default'.
[366] Fix | Delete
*/
[367] Fix | Delete
function esc_attr_e( $text, $domain = 'default' ) {
[368] Fix | Delete
echo esc_attr( translate( $text, $domain ) );
[369] Fix | Delete
}
[370] Fix | Delete
[371] Fix | Delete
/**
[372] Fix | Delete
* Displays translated text that has been escaped for safe use in HTML output.
[373] Fix | Delete
*
[374] Fix | Delete
* If there is no translation, or the text domain isn't loaded, the original text
[375] Fix | Delete
* is escaped and displayed.
[376] Fix | Delete
*
[377] Fix | Delete
* If you need the value for use in PHP, use esc_html__().
[378] Fix | Delete
*
[379] Fix | Delete
* @since 2.8.0
[380] Fix | Delete
*
[381] Fix | Delete
* @param string $text Text to translate.
[382] Fix | Delete
* @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
[383] Fix | Delete
* Default 'default'.
[384] Fix | Delete
*/
[385] Fix | Delete
function esc_html_e( $text, $domain = 'default' ) {
[386] Fix | Delete
echo esc_html( translate( $text, $domain ) );
[387] Fix | Delete
}
[388] Fix | Delete
[389] Fix | Delete
/**
[390] Fix | Delete
* Retrieves translated string with gettext context.
[391] Fix | Delete
*
[392] Fix | Delete
* Quite a few times, there will be collisions with similar translatable text
[393] Fix | Delete
* found in more than two places, but with different translated context.
[394] Fix | Delete
*
[395] Fix | Delete
* By including the context in the pot file, translators can translate the two
[396] Fix | Delete
* strings differently.
[397] Fix | Delete
*
[398] Fix | Delete
* @since 2.8.0
[399] Fix | Delete
*
[400] Fix | Delete
* @param string $text Text to translate.
[401] Fix | Delete
* @param string $context Context information for the translators.
[402] Fix | Delete
* @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
[403] Fix | Delete
* Default 'default'.
[404] Fix | Delete
* @return string Translated context string without pipe.
[405] Fix | Delete
*/
[406] Fix | Delete
function _x( $text, $context, $domain = 'default' ) {
[407] Fix | Delete
return translate_with_gettext_context( $text, $context, $domain );
[408] Fix | Delete
}
[409] Fix | Delete
[410] Fix | Delete
/**
[411] Fix | Delete
* Displays translated string with gettext context.
[412] Fix | Delete
*
[413] Fix | Delete
* @since 3.0.0
[414] Fix | Delete
*
[415] Fix | Delete
* @param string $text Text to translate.
[416] Fix | Delete
* @param string $context Context information for the translators.
[417] Fix | Delete
* @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
[418] Fix | Delete
* Default 'default'.
[419] Fix | Delete
*/
[420] Fix | Delete
function _ex( $text, $context, $domain = 'default' ) {
[421] Fix | Delete
echo _x( $text, $context, $domain );
[422] Fix | Delete
}
[423] Fix | Delete
[424] Fix | Delete
/**
[425] Fix | Delete
* Translates string with gettext context, and escapes it for safe use in an attribute.
[426] Fix | Delete
*
[427] Fix | Delete
* If there is no translation, or the text domain isn't loaded, the original text
[428] Fix | Delete
* is escaped and returned.
[429] Fix | Delete
*
[430] Fix | Delete
* @since 2.8.0
[431] Fix | Delete
*
[432] Fix | Delete
* @param string $text Text to translate.
[433] Fix | Delete
* @param string $context Context information for the translators.
[434] Fix | Delete
* @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
[435] Fix | Delete
* Default 'default'.
[436] Fix | Delete
* @return string Translated text.
[437] Fix | Delete
*/
[438] Fix | Delete
function esc_attr_x( $text, $context, $domain = 'default' ) {
[439] Fix | Delete
return esc_attr( translate_with_gettext_context( $text, $context, $domain ) );
[440] Fix | Delete
}
[441] Fix | Delete
[442] Fix | Delete
/**
[443] Fix | Delete
* Translates string with gettext context, and escapes it for safe use in HTML output.
[444] Fix | Delete
*
[445] Fix | Delete
* If there is no translation, or the text domain isn't loaded, the original text
[446] Fix | Delete
* is escaped and returned.
[447] Fix | Delete
*
[448] Fix | Delete
* @since 2.9.0
[449] Fix | Delete
*
[450] Fix | Delete
* @param string $text Text to translate.
[451] Fix | Delete
* @param string $context Context information for the translators.
[452] Fix | Delete
* @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
[453] Fix | Delete
* Default 'default'.
[454] Fix | Delete
* @return string Translated text.
[455] Fix | Delete
*/
[456] Fix | Delete
function esc_html_x( $text, $context, $domain = 'default' ) {
[457] Fix | Delete
return esc_html( translate_with_gettext_context( $text, $context, $domain ) );
[458] Fix | Delete
}
[459] Fix | Delete
[460] Fix | Delete
/**
[461] Fix | Delete
* Translates and retrieves the singular or plural form based on the supplied number.
[462] Fix | Delete
*
[463] Fix | Delete
* Used when you want to use the appropriate form of a string based on whether a
[464] Fix | Delete
* number is singular or plural.
[465] Fix | Delete
*
[466] Fix | Delete
* Example:
[467] Fix | Delete
*
[468] Fix | Delete
* printf( _n( '%s person', '%s people', $count, 'text-domain' ), number_format_i18n( $count ) );
[469] Fix | Delete
*
[470] Fix | Delete
* @since 2.8.0
[471] Fix | Delete
* @since 5.5.0 Introduced `ngettext-{$domain}` filter.
[472] Fix | Delete
*
[473] Fix | Delete
* @param string $single The text to be used if the number is singular.
[474] Fix | Delete
* @param string $plural The text to be used if the number is plural.
[475] Fix | Delete
* @param int $number The number to compare against to use either the singular or plural form.
[476] Fix | Delete
* @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
[477] Fix | Delete
* Default 'default'.
[478] Fix | Delete
* @return string The translated singular or plural form.
[479] Fix | Delete
*/
[480] Fix | Delete
function _n( $single, $plural, $number, $domain = 'default' ) {
[481] Fix | Delete
$translations = get_translations_for_domain( $domain );
[482] Fix | Delete
$translation = $translations->translate_plural( $single, $plural, $number );
[483] Fix | Delete
[484] Fix | Delete
/**
[485] Fix | Delete
* Filters the singular or plural form of a string.
[486] Fix | Delete
*
[487] Fix | Delete
* @since 2.2.0
[488] Fix | Delete
*
[489] Fix | Delete
* @param string $translation Translated text.
[490] Fix | Delete
* @param string $single The text to be used if the number is singular.
[491] Fix | Delete
* @param string $plural The text to be used if the number is plural.
[492] Fix | Delete
* @param int $number The number to compare against to use either the singular or plural form.
[493] Fix | Delete
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
[494] Fix | Delete
*/
[495] Fix | Delete
$translation = apply_filters( 'ngettext', $translation, $single, $plural, $number, $domain );
[496] Fix | Delete
[497] Fix | Delete
/**
[498] Fix | Delete
* Filters the singular or plural form of a string for a domain.
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function