gettext_with_context
最后更新于:2021-11-26 10:43:24
apply_filters( ‘gettext_with_context’, string $translation, string $text, string $context, string $domain )
Filters text with its translation based on context information.
参数
- $translation
-
(string)
Translated text. - $text
-
(string)
Text to translate. - $context
-
(string)
Context information for the translators. - $domain
-
(string)
Text domain. Unique identifier for retrieving translated strings.
源文件
文件: gc-includes/l10n.php
/** * @param string $translated * @param string $text * @param string $context * @param string $domain * @return string */ function example_gettext_with_context( $translated, $text, $context, $domain ) { if ( 'example-plugin' == $domain ) { if ( 'directions' == $text && 'directions on map' == $context ) { $translated = 'map directions'; // not recipe instructions! } } return $translated; } add_filter( 'gettext_with_context', 'example_gettext_with_context', 10, 4 );