gettext_with_context_{$domain}
云策文档标注
概述
本文档介绍 WordPress 中的 gettext_with_context_{$domain} 过滤器,它基于上下文信息过滤文本及其翻译,用于特定文本域。该过滤器是动态钩子,允许开发者修改翻译字符串。
关键要点
- gettext_with_context_{$domain} 是一个过滤器,用于基于上下文信息过滤文本翻译,其中 $domain 是动态部分,指文本域。
- 参数包括 $translation(已翻译文本)、$text(待翻译文本)、$context(翻译上下文信息)和 $domain(文本域标识符)。
- 该过滤器通过 apply_filters 调用,可用于自定义翻译逻辑,例如在特定上下文中调整翻译。
- 相关函数 translate_with_gettext_context() 用于在指定上下文中检索文本翻译。
- 该过滤器自 WordPress 5.5.0 版本引入。
原文内容
Filters text with its translation based on context information for a domain.
Description
The dynamic portion of the hook name, $domain, refers to the text domain.
Parameters
$translationstring-
Translated text.
$textstring-
Text to translate.
$contextstring-
Context information for the translators.
$domainstring-
Text domain. Unique identifier for retrieving translated strings.
Source
$translation = apply_filters( "gettext_with_context_{$domain}", $translation, $text, $context, $domain );
Changelog
| Version | Description |
|---|---|
| 5.5.0 | Introduced. |