
通过MemberPress实现WordPress接入ChatGPT终极指南
_get_path_to_translation_from_lang_dir ( $domain )
_get_path_to_translation_from_lang_dir是一个WordPress函数,它返回特定文本域和语言目录的翻译文件的路径: 这个函数需要三个参数:文本域、语言目录和翻译文件的文件扩展名。它在指定的语言目录中搜索翻译文件,如果文件存在,则返回该文件的路径。
获取当前地区语言目录中的翻译文件的路径。
保存一个可用的.mo文件的缓存列表以提高性能。
function _get_path_to_translation_from_lang_dir( $domain ) { _deprecated_function( __FUNCTION__, '6.1.0', 'WP_Textdomain_Registry' ); static $cached_mofiles = null; if ( null === $cached_mofiles ) { $cached_mofiles = array(); $locations = array( WP_LANG_DIR . '/plugins', WP_LANG_DIR . '/themes', ); foreach ( $locations as $location ) { $mofiles = glob( $location . '/*.mo' ); if ( $mofiles ) { $cached_mofiles = array_merge( $cached_mofiles, $mofiles ); } } } $locale = determine_locale(); $mofile = "{$domain}-{$locale}.mo"; $path = WP_LANG_DIR . '/plugins/' . $mofile; if ( in_array( $path, $cached_mofiles, true ) ) { return $path; } $path = WP_LANG_DIR . '/themes/' . $mofile; if ( in_array( $path, $cached_mofiles, true ) ) { return $path; } return false; }