ZBLOG插件翻译文章标题为英文作为别名(涂涂研版)不能用了
浏览量:873
百度翻译改了接口,需要注册后获得APP_ID和SEC_KEY
并且:若当月翻译字符数≤2百万,当月免费;若超过2百万字符,按照49元/百万字符支付当月全部翻译字符数费用。
修改如下:
上传百度翻译php的DEMO文件baidu_transapi.php到插件文件夹zb_users/plugin/tt_Alias_Translation/,修改里面的APP_ID和SEC_KEY,
修改插件文件change.php:
<?php
require '../../../zb_system/function/c_system_base.php';
require '../../../zb_system/function/c_system_admin.php';
require './baidu_transapi.php';
$zbp->Load();
$action='root';
if (!$zbp->CheckRights($action)) {$zbp->ShowError(6);die();}
if (!$zbp->CheckPlugin('tt_Alias_Translation')) {$zbp->ShowError(48);die();}
$response=translate($_POST['title'], 'zh', 'en');
$trans_title = urldecode($response['trans_result'][0]['dst']);
$trans_title = str_replace(array("-_", "_", " "), array("-","","-"), $trans_title);
echo $trans_title;
?>解决。


感谢支持与鼓励~