返回介绍

_nx_noop()

发布于 2017-09-11 10:42:21 字数 3564 浏览 1062 评论 0 收藏 0

_nx_noop( string $singular,  string $plural,  string $context,  string $domain = null )

Registers plural strings with gettext context in POT file, but does not translate them.


description

Used when you want to keep structures with translatable plural strings and use them later when the number is known.

Example of a generic phrase which is disambiguated via the context parameter:

$messages = array(
    'people'  => _nx_noop( '%s group', '%s groups', 'people', 'text-domain' ),
    'animals' => _nx_noop( '%s group', '%s groups', 'animals', 'text-domain' ),
);
...
$message = $messages[ $type ];
printf( translate_nooped_plural( $message, $count, 'text-domain' ), number_format_i18n( $count ) );

参数

$singular

(string) (Required) Singular form to be localized.

$plural

(string) (Required) Plural form to be localized.

$context

(string) (Required) Context information for the translators.

$domain

(string) (Optional) Text domain. Unique identifier for retrieving translated strings.

Default value: null


返回值

(array) { Array of translation information for the strings. @type string $0 Singular form to be localized. No longer used. @type string $1 Plural form to be localized. No longer used. @type string $2 Context information for the translators. No longer used. @type string $singular Singular form to be localized. @type string $plural Plural form to be localized. @type string $context Context information for the translators. @type string $domain Text domain. }


源代码

File: wp-includes/l10n.php

function _nx_noop( $singular, $plural, $context, $domain = null ) {
	return array( 0 => $singular, 1 => $plural, 2 => $context, 'singular' => $singular, 'plural' => $plural, 'context' => $context, 'domain' => $domain );
}

更新日志

Versiondescription
2.8.0Introduced.

相关函数

Used By

  • wp-admin/includes/class-wp-comments-list-table.php: WP_Comments_List_Table::get_views()

User Contributed Notes

  1. Skip to note content You must log in to vote on the helpfulness of this noteVote results for this note: -1You must log in to vote on the helpfulness of this note Contributed by Codex
    
    $labels = array(
    	'draft' => array( _nx_noop( '%s Draft', '%s Drafts', 'post' ), _nx_noop( '%s Draft', '%s Drafts', 'page' ) ),
    	'publish' => array( _nx_noop( '%s Published', '%s Published', 'post' ), _nx_noop( '%s Published', '%s Published', 'page' ) ),
    );
    if ( $post_type == 'page' ) {
    	$labels = $labels[ $post_status ][1];
    } else {
    	$labels = $labels[ $post_status ][0];
    }
    $usable_text = sprintf( translate_nooped_plural( $labels, $count, $domain ), $count );
    

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

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

发布评论

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