我开发了一个包含 400 多个单词和短语的插件。有一些短语对插件的功能非常重要,但很难完成所有翻译的 90% [在 wordpress.org] 以确保设置了必要的 20 个。
我需要检查当前是否存在插件的翻译,否则会为有限数量的语言提供后备。
例子:
<?php
if (wp_current_translation_exists())
{
$local_phrase = __('Some word', 'text-domain');
}
else
{
$language_code = substr(WP_LANG, 0, 2);
switch ($language_code)
{
case 'fr':
$local_phrase = 'Un mot';
break;
case 'de':
$local_phrase = 'Ein Wort';
break;
default:
$local_phrase = __('Some word', 'text-domain');
break;
}
}
?>
缺少的函数显示为:wp_current_translation_exists()
。