钩子文档

load_translation_file

💡 云策文档标注

概述

load_translation_file 是一个 WordPress 过滤器,用于修改加载指定文本域翻译文件的路径。它类似于 load_textdomain_mofile 过滤器,但支持 MO 或 PHP 文件路径。

关键要点

  • 过滤器名称:load_translation_file
  • 参数:$file(翻译文件路径字符串)、$domain(文本域字符串)、$locale(区域设置字符串)
  • 用途:允许开发者自定义翻译文件的加载路径,支持 MO 或 PHP 格式
  • 相关函数:与 load_textdomain() 配合使用,用于加载 .mo 文件到指定文本域
  • 版本历史:在 WordPress 6.5.0 中引入,6.6.0 版本增加了 $locale 参数

📄 原文内容

Filters the file path for loading translations for the given text domain.

Description

Similar to the ‘load_textdomain_mofile’ filter with the difference that the file path could be for an MO or PHP file.

Parameters

$filestring
Path to the translation file to load.
$domainstring
The text domain.
$localestring
The locale.

Source

$file = (string) apply_filters( 'load_translation_file', $file, $domain, $locale );

Changelog

Version Description
6.6.0 Added the $locale parameter.
6.5.0 Introduced.