api适配多语言

feat/task1-c-wallet
gongfuxiang 2023-03-24 16:52:30 +08:00
parent f23cdb5372
commit d614f4bf10
8 changed files with 76 additions and 12 deletions

View File

@ -145,10 +145,10 @@ class Article extends Common
];
$ret = SystemBaseService::DataReturn($result);
} else {
$ret = DataReturn('文章不存在或已删除', -1);
$ret = DataReturn(MyLang('article.article_no_data_tips'), -1);
}
} else {
$ret = DataReturn('文章ID有误', -1);
$ret = DataReturn(MyLang('article.article_id_params_tips'), -1);
}
return ApiService::ApiDataReturn($ret);
}

View File

@ -130,7 +130,7 @@ class Common extends BaseController
{
if(MyC('home_site_state') != 1)
{
exit(json_encode(DataReturn(MyC('home_site_close_reason', '升级中...'), -10000)));
exit(json_encode(DataReturn(MyC('home_site_close_reason', MyLang('upgrading_tips')), -10000)));
}
}
@ -228,7 +228,7 @@ class Common extends BaseController
{
if(!empty($this->user) && !empty($this->data_request['token']) && $this->data_request['token'] != ApiService::CreatedUserToken($this->user['id']))
{
exit(json_encode(DataReturn('token非法', -1000)));
exit(json_encode(DataReturn(MyLang('token_error_tips'), -1000)));
}
}
@ -244,7 +244,7 @@ class Common extends BaseController
*/
public function __call($method, $args)
{
return ApiService::ApiDataReturn(DataReturn($method.' 非法访问', -1000));
return ApiService::ApiDataReturn(DataReturn(MyLang('illegal_access_tips').'('.$method.')', -1000));
}
}
?>

View File

@ -34,7 +34,7 @@ class Error extends Common
*/
public function __call($method, $args)
{
return ApiService::ApiDataReturn(DataReturn(RequestController().' 控制器不存在', -1000));
return ApiService::ApiDataReturn(DataReturn(MyLang('controller_not_exist_tips').'('.RequestController().')', -1000));
}
}
?>

View File

@ -44,7 +44,7 @@ class Order extends Common
}
/**
* [Index 获取订单列表]
* 获取订单列表
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
@ -174,14 +174,14 @@ class Order extends Common
// 是否已评论
if($data['data'][0]['user_is_comments'] > 0)
{
$ret = DataReturn('你已进行过评论', -100);
$ret = DataReturn(MyLang('order.form_you_have_commented_tips'), -100);
} else {
// 返回数据
$result = [
'data' => $data['data'][0],
'editor_path_type' => ResourcesService::EditorPathTypeValue('order_comments-'.$this->user['id'].'-'.$data['data'][0]['id']),
];
$ret = DataReturn('你已进行过评论', 0, $result);
$ret = DataReturn(MyLang('order.form_you_have_commented_tips'), 0, $result);
}
} else {
$ret = DataReturn(MyLang('no_data'), -100);

View File

@ -53,17 +53,17 @@ class Plugins extends Common
[
'checked_type' => 'empty',
'key_name' => 'pluginsname',
'error_msg' => '应用名称有误',
'error_msg' => MyLang('plugins_name_tips'),
],
[
'checked_type' => 'empty',
'key_name' => 'pluginscontrol',
'error_msg' => '应用控制器有误',
'error_msg' => MyLang('plugins_control_tips'),
],
[
'checked_type' => 'empty',
'key_name' => 'pluginsaction',
'error_msg' => '应用操作方法有误',
'error_msg' => MyLang('plugins_action_tips'),
],
];
$ret = ParamsChecked($params['data_request'], $p);

32
app/api/lang/en.php Normal file
View File

@ -0,0 +1,32 @@
<?php
// +----------------------------------------------------------------------
// | ShopXO 国内领先企业级B2C免费开源电商系统
// +----------------------------------------------------------------------
// | Copyright (c) 2011~2099 http://shopxo.net All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( https://opensource.org/licenses/mit-license.php )
// +----------------------------------------------------------------------
// | Author: Devil
// +----------------------------------------------------------------------
/**
* 模块语言包-英文
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2016-12-01T21:51:08+0800
*/
return [
// 基础公共
'token_error_tips' => 'Illegal token',
// 文章
'article' => [
'article_no_data_tips' => 'Article does not exist or has been deleted',
'article_id_params_tips' => 'Incorrect article ID',
],
// 订单管理
'order' => [
'form_you_have_commented_tips' => 'You have already commented',
],
];
?>

0
app/api/lang/index.html Normal file
View File

32
app/api/lang/zh.php Normal file
View File

@ -0,0 +1,32 @@
<?php
// +----------------------------------------------------------------------
// | ShopXO 国内领先企业级B2C免费开源电商系统
// +----------------------------------------------------------------------
// | Copyright (c) 2011~2099 http://shopxo.net All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( https://opensource.org/licenses/mit-license.php )
// +----------------------------------------------------------------------
// | Author: Devil
// +----------------------------------------------------------------------
/**
* 模块语言包-中文
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2016-12-01T21:51:08+0800
*/
return [
// 基础公共
'token_error_tips' => 'token非法',
// 文章
'article' => [
'article_no_data_tips' => '文章不存在或已删除',
'article_id_params_tips' => '文章ID有误',
],
// 订单管理
'order' => [
'form_you_have_commented_tips' => '你已进行过评论',
],
];
?>