我有一个主题是为翻译而设置的,但没有任何翻译。我使用poedit自动检测字符串,然后将其完整翻译。然而,某些元素在管理或网站上没有翻译。
我可以在poedit中看到,我翻译了所有的字符串,包括那些没有在现场翻译的字符串。一些未翻译的字符串出现在前端,但大部分在admin中。
我注意到,似乎没有翻译的字符串是通过“add\\u action”加载的字符串。因此,例如,主题附带了一些自定义帖子类型,其中1是用于事件的。在admin中,除了与元盒关联的字符串外,与此自定义帖子类型相关的所有内容都在翻译。
例如,以下代码创建的管理内容不会在admin中翻译;
$meta_box_events = array(
\'id\' => \'core-meta-box-events\',
\'title\' => __(\'Events Options\', CORE_THEME_NAME),
\'post_type\' => \'event\',
\'context\' => \'normal\',
\'priority\' => \'high\',
\'fields\' => array(
array(
\'name\' => __(\'Event Month\', CORE_THEME_NAME),
\'desc\' => __(\'Choose the event month \', CORE_THEME_NAME),
\'id\' => \'core_event_month\',
\'type\' => \'select\',
\'options\' => array(__(\'January\', CORE_THEME_NAME),
__(\'February\', CORE_THEME_NAME),
__(\'March\', CORE_THEME_NAME),
__(\'April\', CORE_THEME_NAME),
__(\'May\', CORE_THEME_NAME),
__(\'June\', CORE_THEME_NAME),
__(\'July\', CORE_THEME_NAME),
__(\'August\', CORE_THEME_NAME),
__(\'September\', CORE_THEME_NAME),
__(\'October\', CORE_THEME_NAME),
__(\'November\', CORE_THEME_NAME),
__(\'December\', CORE_THEME_NAME)
)
),
array(
\'name\' => __(\'Event Day\', CORE_THEME_NAME),
\'desc\' => __(\'Choose the event day. \', CORE_THEME_NAME),
\'id\' => \'core_event_day\',
\'type\' => \'select\',
\'options\' => array( \'1\',
\'2\',
\'3\',
\'4\',
\'5\',
\'6\',
\'7\',
\'8\',
\'9\',
\'10\',
\'11\',
\'12\',
\'13\',
\'14\',
\'15\',
\'16\',
\'17\',
\'18\',
\'19\',
\'20\',
\'21\',
\'22\',
\'23\',
\'24\',
\'25\',
\'26\',
\'27\',
\'28\',
\'29\',
\'30\',
\'31\'
)
),
array(
\'name\' => __(\'Event Year\', CORE_THEME_NAME),
\'desc\' => __(\'Enter the event year using this format <em>0000.</em>\', CORE_THEME_NAME),
\'id\' => \'core_event_year\',
\'type\' => \'text\',
\'std\' => \'\'
),
array(
\'name\' => __(\'Event Time\', CORE_THEME_NAME),
\'desc\' => __(\'Enter the event time using this format <em>00:00AM/PM to 00:00AM/PM.</em>\', CORE_THEME_NAME),
\'id\' => \'core_event_time\',
\'type\' => \'text\',
\'std\' => \'\'
),
array(
\'name\' => __(\'Event Location\', CORE_THEME_NAME),
\'desc\' => __(\'Enter the event location, example: <em>Cramton Auditorium.</em>\', CORE_THEME_NAME),
\'id\' => \'core_event_location\',
\'type\' => \'text\',
\'std\' => \'\'
),
array(
\'name\' => __(\'Event City\', CORE_THEME_NAME),
\'desc\' => __(\'Enter the city of the event, example: <em>London.</em>\', CORE_THEME_NAME),
\'id\' => \'core_event_city\',
\'type\' => \'text\',
\'std\' => \'\'
),
array(
\'name\' => __(\'Event Zip Code\', CORE_THEME_NAME),
\'desc\' => __(\'Enter the address zip code, example: <em>10308 89.</em>\', CORE_THEME_NAME),
\'id\' => \'core_event_zip\',
\'type\' => \'text\',
\'std\' => \'\'
),
array(
\'name\' => __(\'Event Country\', CORE_THEME_NAME),
\'desc\' => __(\'Enter the event country, example: <em>United Kingdom.</em>\', CORE_THEME_NAME),
\'id\' => \'core_event_country\',
\'type\' => \'text\',
\'std\' => \'\'
),
array(
\'name\' => __(\'Event Phone\', CORE_THEME_NAME),
\'desc\' => __(\'Enter the phone info, example: <em>+44 (0)20 7040 8037.</em>\', CORE_THEME_NAME),
\'id\' => \'core_event_phone\',
\'type\' => \'text\',
\'std\' => \'\'
),
array(
\'name\' => __(\'Event Map Latitude\', CORE_THEME_NAME),
\'desc\' => __(\'Enter the google map longitude information, example: <em>-12.8809532.</em>\', CORE_THEME_NAME),
\'id\' => \'core_event_lat\',
\'type\' => \'text\',
\'std\' => \'\'
),
array(
\'name\' => __(\'Event Map Longitude\', CORE_THEME_NAME),
\'desc\' => __(\'Enter the google map longitude information, example: <em>-38.4174871.</em>\', CORE_THEME_NAME),
\'id\' => \'core_event_lon\',
\'type\' => \'text\',
\'std\' => \'\'
)
)
);
add_action(\'add_meta_boxes\', \'core_add_metabox_events\');
“CORE\\u THEME\\u NAME”正在被选中,我也肯定会回应它。
因此,我对WordPress的了解有限,这让我怀疑翻译是在加载此代码之前触发的。然而,翻译被称为主题的功能。php如下:;
add_action(\'after_setup_theme\', \'lang_setup\');
function lang_setup(){
load_theme_textdomain(CORE_THEME_NAME, CORE_DIRECTORY . \'/languages\');
}
据我所见,这应该确保在加载所有主题组件后加载textdomain。那么,为什么这些字符串没有在事件帖子的站点管理中被翻译??
如有任何想法/建议/等,将不胜感激。
谢谢