返回介绍

translate_nooped_plural()

发布于 2017-09-11 10:42:11 字数 2764 浏览 947 评论 0 收藏 0

translate_nooped_plural( array $nooped_plural,  int $count,  string $domain = 'default' )

Translates and retrieves the singular or plural form of a string that’s been registered with _n_noop() or _nx_noop().


description

Used when you want to use a translatable plural string once the number is known.

Example:

$message = _n_noop( '%s post', '%s posts', 'text-domain' );
...
printf( translate_nooped_plural( $message, $count, 'text-domain' ), number_format_i18n( $count ) );

参数

$nooped_plural

(array) (Required) Array with singular, plural, and context keys, usually the result of _n_noop() or _nx_noop().

$count

(int) (Required) Number of objects.

$domain

(string) (Optional) Text domain. Unique identifier for retrieving translated strings. If $nooped_plural contains a text domain passed to _n_noop() or _nx_noop(), it will override this value.

Default value: 'default'


返回值

(string) Either $single or $plural translated text.


源代码

File: wp-includes/l10n.php

function translate_nooped_plural( $nooped_plural, $count, $domain = 'default' ) {
	if ( $nooped_plural['domain'] )
		$domain = $nooped_plural['domain'];

	if ( $nooped_plural['context'] )
		return _nx( $nooped_plural['singular'], $nooped_plural['plural'], $count, $nooped_plural['context'], $domain );
	else
		return _n( $nooped_plural['singular'], $nooped_plural['plural'], $count, $domain );
}

更新日志

Versiondescription
3.1.0Introduced.

相关函数

Uses

  • wp-includes/l10n.php: _nx()
  • wp-includes/l10n.php: _n()

Used By

  • wp-includes/widgets/class-wp-widget-media.php: WP_Widget_Media::display_media_state()
  • wp-admin/includes/media.php: media_upload_library_form()
  • wp-admin/includes/class-wp-comments-list-table.php: WP_Comments_List_Table::get_views()
  • wp-admin/includes/class-wp-posts-list-table.php: WP_Posts_List_Table::get_views()
  • wp-includes/category-template.php: wp_generate_tag_cloud()

User Contributed Notes

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文