钩子文档

translations_api_result

💡 云策文档标注

概述

本文档介绍了 translations_api_result 过滤器,用于过滤 Translation Installation API 的响应结果。它允许开发者在获取翻译数据时修改或扩展返回的数组。

关键要点

  • 过滤器名称:translations_api_result
  • 参数:$res(成功时为翻译关联数组,失败时为 WP_Error)、$type(请求的翻译类型)、$args(Translation API 参数)
  • 返回:应用过滤器后的结果,通常通过 apply_filters 调用
  • 相关函数:translations_api(),用于从 WordPress Translation API 检索翻译
  • 引入版本:WordPress 4.0.0

代码示例

return apply_filters( 'translations_api_result', $res, $type, $args );

📄 原文内容

Filters the Translation Installation API response results.

Parameters

$resarray|WP_Error
On success an associative array of translations, WP_Error on failure.
  • translations array
    List of translations, each an array of data.
    • ...$0 array
      • language string
        Language code.
      • version string
        WordPress version.
      • updated string
        Date the translation was last updated, in MySQL datetime format.
      • english_name string
        English name of the language.
      • native_name string
        Native name of the language.
      • package string
        URL to download the translation package.
      • iso string[]
        Array of ISO language codes.
      • strings array
        Array of translated strings used in the installation process.
        }
$typestring
The type of translations being requested.
$argsobject
Translation API arguments.

Source

return apply_filters( 'translations_api_result', $res, $type, $args );

Changelog

VersionDescription
4.0.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.