Commit ae06a161 authored by shajiaiming's avatar shajiaiming

多语言配置化

parent 485ab183
......@@ -142,9 +142,9 @@ class CoinController extends BaseController
$coin_infos = Coin::getCoinInfoByIds($coin_ids, $select, 'id');
foreach ($coin_infos as $key => &$val) {
$nickname = json_decode($val['nickname'], true);
$val['nickname'] = $nickname[$this->lang];
$val['nickname'] = isset($nickname[$this->lang]) ? $nickname[$this->lang] : '';
$introduce = json_decode($val['introduce'], true);
$val['introduce'] = $introduce[$this->lang];
$val['introduce'] = isset($introduce[$this->lang]) ? $introduce[$this->lang] : '';
}
//获取行情信息
$coin_names = array_column($coin_infos, 'name');
......
......@@ -92,15 +92,11 @@ class ApplicationCategoryController extends BaseController
$fields = ['id', 'name', 'sort', 'icon', 'banner', 'banner_url'];
$params = $this->initParams(Yii::$app->request->post(), $fields);
$params['platform_id'] = Yii::$app->user->identity->platform_id;
$lang = [
'zh-CN',
'en-US',
'ja'
];
$name_arr = $params['name'];
$name = [];
foreach ($name_arr as $key => $val) {
$name[$lang[$key]] = $val;
foreach (Yii::$app->params['lang'] as $key => $val) {
$name[$val] = isset($name_arr[$val]) ? $name_arr[$val] : '';
}
unset($params['name']);
......@@ -124,15 +120,10 @@ class ApplicationCategoryController extends BaseController
$category = CoinApplicationCategory::getCategoryById($params['id']);
$params['platform_id'] = $category->platform_id;
$application_category->setScenario(CoinApplicationCategoryForm::SCENARIO_EDIT);
$lang = [
'zh-CN',
'en-US',
'ja'
];
$name_arr = $params['name'];
$name = [];
foreach ($name_arr as $key => $val) {
$name[$lang[$key]] = $val;
foreach (Yii::$app->params['lang'] as $key => $val) {
$name[$val] = isset($name_arr[$val]) ? $name_arr[$val] : '';
}
unset($params['name']);
......@@ -150,6 +141,7 @@ class ApplicationCategoryController extends BaseController
$coin['name_ja'] = isset($name_arr['ja']) ? $name_arr['ja'] : '';
$coin['name_zh'] = isset($name_arr['zh-CN']) ? $name_arr['zh-CN'] : '';
$coin['name_en'] = isset($name_arr['en-US']) ? $name_arr['en-US'] : '';
$coin['name_ko'] = isset($name_arr['ko']) ? $name_arr['ko'] : '';
$this->layout = false;
return $this->render('edit', ['model' => $coin]);
}
......
......@@ -65,15 +65,10 @@ class ApplicationController extends BaseController
$category_id = Yii::$app->request->get('category_id');
$fields = ['category_id', 'h5_icon', 'official_url', 'introduce_image', 'show_width', 'show_height', 'open_type', 'open_type_app', 'platform_type', 'name', 'sort', 'icon', 'type', 'native_url', 'native_login_url', 'h5_url', 'android_url', 'ios_url', 'app_store_url', 'advertise', 'description', 'redirect_type', 'platform_id'];
$data = Yii::$app->request->post();
$lang = [
'zh-CN',
'en-US',
'ja'
];
$name_arr = $data['name'];
$name = [];
foreach ($name_arr as $key => $val){
$name[$lang[$key]] = $val;
foreach (Yii::$app->params['lang'] as $key => $val) {
$name[$val] = isset($name_arr[$val]) ? $name_arr[$val] : '';
}
unset($data['name']);
$data['name'] = $name;
......@@ -104,21 +99,15 @@ class ApplicationController extends BaseController
$fields = ['category_id', 'id', 'h5_icon', 'official_url', 'introduce_image', 'show_width', 'show_height', 'open_type', 'open_type_app', 'platform_type', 'name', 'sort', 'icon', 'type', 'native_url', 'native_login_url', 'h5_url', 'android_url', 'ios_url', 'app_store_url', 'advertise', 'description', 'redirect_type', 'platform_id'];
$data = Yii::$app->request->post();
$lang = [
'zh-CN',
'en-US',
'ja'
];
$name_arr = $data['name'];
$name = [];
foreach ($name_arr as $key => $val){
$name[$lang[$key]] = $val;
foreach (Yii::$app->params['lang'] as $key => $val) {
$name[$val] = isset($name_arr[$val]) ? $name_arr[$val] : '';
}
unset($data['name']);
$data['name'] = $name;
$data['open_type_app'] = (0 == $data['open_type_app']) ? 1 : $data['open_type_app'];
#var_dump($data);exit;
$params = array_merge($data, ['platform_id' => Yii::$app->user->identity->platform_id]);
$params = $this->initParams($params, $fields);
$coin_applicateion_form = new CoinApplicationForm();
......@@ -168,6 +157,7 @@ class ApplicationController extends BaseController
$applicate['name_ja'] = $name_arr['ja'];
$applicate['name_en'] = $name_arr['en-US'];
$applicate['name_zh'] = $name_arr['zh-CN'];
$applicate['name_ko'] = $name_arr['ko'];
$this->layout = false;
return $this->render('edit', ['item' => $applicate, 'category_id' => $category_id]);
}
......
......@@ -95,22 +95,18 @@ class CoinController extends BaseController
$data['name'] = strtoupper(trim($data['name']));
$data['platform'] = $data['platform'];
$data['chain'] = strtoupper($data['chain']);
$lang = [
'zh-CN',
'en-US',
'ja',
'ko'
];
$nickname_arr = $data['nickname'];
$introduce_arr = $data['introduce'];
$nickname = [];
$introduce = [];
foreach ($nickname_arr as $key => $val) {
$nickname[$lang[$key]] = trim($val);
foreach (Yii::$app->params['lang'] as $key => $val) {
$nickname[$val] = isset($nickname_arr[$val]) ? $nickname_arr[$val] : '';
}
foreach ($introduce_arr as $key => $val) {
$introduce[$lang[$key]] = $val;
foreach (Yii::$app->params['lang'] as $key => $val) {
$introduce[$val] = isset($introduce_arr[$val]) ? $introduce_arr[$val] : '';
}
unset($data['nickname']);
unset($data['introduce']);
$data['nickname'] = $nickname;
......@@ -168,21 +164,15 @@ class CoinController extends BaseController
$can = true;
}
if ($can) {
$lang = [
'zh-CN',
'en-US',
'ja',
'ko'
];
$nickname_arr = $data['nickname'];
$introduce_arr = $data['introduce'];
$nickname = [];
$introduce = [];
foreach ($nickname_arr as $key => $val) {
$nickname[$lang[$key]] = $val;
foreach (Yii::$app->params['lang'] as $key => $val) {
$nickname[$val] = isset($nickname_arr[$val]) ? $nickname_arr[$val] : '';
}
foreach ($introduce_arr as $key => $val) {
$introduce[$lang[$key]] = $val;
foreach (Yii::$app->params['lang'] as $key => $val) {
$introduce[$val] = isset($introduce_arr[$val]) ? $introduce_arr[$val] : '';
}
unset($data['nickname']);
$data['nickname'] = $nickname;
......
......@@ -21,7 +21,7 @@
<div class="layui-inline">
<label class="layui-form-label">中文名</label>
<div class="layui-input-block" style="width: 250px">
<input class="layui-input" name="name[]" required lay-verify="required" placeholder=""
<input class="layui-input" name="name[zh-CN]" required lay-verify="required" placeholder=""
autocomplete="off" value=""
class="layui-input">
</div>
......@@ -29,13 +29,19 @@
<div class="layui-inline">
<label class="layui-form-label">英文名</label>
<div class="layui-input-block" style="width: 250px">
<input class="layui-input" name="name[]" value="">
<input class="layui-input" name="name[en-US]" value="">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">日文名</label>
<div class="layui-input-block" style="width: 250px">
<input class="layui-input" name="name[]" value="">
<input class="layui-input" name="name[ja]" value="">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">韩文名</label>
<div class="layui-input-block" style="width: 250px">
<input class="layui-input" name="name[ko]" value="">
</div>
</div>
<div class="layui-form-item layui-form-text">
......
......@@ -21,19 +21,25 @@
<div class="layui-inline">
<label class="layui-form-label">中文名</label>
<div class="layui-input-block" style="width: 250px">
<input class="layui-input" name="name[]" value="<?= $model['name_zh'] ?>">
<input class="layui-input" name="name[zh-CN]" value="<?= $model['name_zh'] ?>">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">英文名</label>
<div class="layui-input-block" style="width: 250px">
<input class="layui-input" name="name[]" value="<?= $model['name_en'] ?>">
<input class="layui-input" name="name[en-US]" value="<?= $model['name_en'] ?>">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">日文名</label>
<div class="layui-input-block" style="width: 250px">
<input class="layui-input" name="name[]" value="<?= $model['name_ja'] ?>">
<input class="layui-input" name="name[ja]" value="<?= $model['name_ja'] ?>">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">韩文名</label>
<div class="layui-input-block" style="width: 250px">
<input class="layui-input" name="name[ko]" value="<?= $model['name_ko'] ?>">
</div>
</div>
<div class="layui-form-item layui-form-text">
......
......@@ -48,19 +48,25 @@
<div class="layui-form-item">
<label class="layui-form-label">中文名</label>
<div class="layui-input-block">
<input class="layui-input" name="name[]" value="" lay-verify="required">
<input class="layui-input" name="name[zh-CN]" value="" lay-verify="required">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">英文名</label>
<div class="layui-input-block">
<input class="layui-input" name="name[]" value="" lay-verify="required">
<input class="layui-input" name="name[en-US]" value="" lay-verify="required">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">日文名</label>
<div class="layui-input-block">
<input class="layui-input" name="name[]" value="" lay-verify="required">
<input class="layui-input" name="name[ja]" value="" lay-verify="required">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">韩文名</label>
<div class="layui-input-block">
<input class="layui-input" name="name[ko]" value="" lay-verify="required">
</div>
</div>
<div class="layui-form-item">
......
......@@ -51,19 +51,25 @@
<div class="layui-form-item">
<label class="layui-form-label">中文名</label>
<div class="layui-input-block">
<input class="layui-input" name="name[]" value="<?= $item['name_zh'] ?>" lay-verify="required">
<input class="layui-input" name="name[zh-CN]" value="<?= $item['name_zh'] ?>" lay-verify="required">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">英文名</label>
<div class="layui-input-block">
<input class="layui-input" name="name[]" value="<?= $item['name_en'] ?>" lay-verify="required">
<input class="layui-input" name="name[en-US]" value="<?= $item['name_en'] ?>" lay-verify="required">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">日文名</label>
<div class="layui-input-block">
<input class="layui-input" name="name[]" value="<?= $item['name_ja'] ?>" lay-verify="required">
<input class="layui-input" name="name[ja]" value="<?= $item['name_ja'] ?>" lay-verify="required">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">韩文名</label>
<div class="layui-input-block">
<input class="layui-input" name="name[ko]" value="<?= $item['name_ko'] ?>" lay-verify="required">
</div>
</div>
<div class="layui-form-item">
......
......@@ -34,19 +34,25 @@
<div class="layui-inline">
<label class="layui-form-label">中文名</label>
<div class="layui-input-block" style="width: 190px">
<input class="layui-input" name="nickname[]" value="<?= $model->nickname['zh-CN'] ?>">
<input class="layui-input" name="nickname[zh-CN]" value="<?= $model->nickname['zh-CN'] ?>">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">英文名</label>
<div class="layui-input-block" style="width: 190px">
<input class="layui-input" name="nickname[]" value="<?= $model->nickname['en-US'] ?>">
<input class="layui-input" name="nickname[en-US]" value="<?= $model->nickname['en-US'] ?>">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">日文名</label>
<div class="layui-input-block" style="width: 190px">
<input class="layui-input" name="nickname[]" value="<?= $model->nickname['ja'] ?>">
<input class="layui-input" name="nickname[ja]" value="<?= $model->nickname['ja'] ?>">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">韩文名</label>
<div class="layui-input-block" style="width: 190px">
<input class="layui-input" name="nickname[ko]" value="<?= $model->nickname['ko'] ?>">
</div>
</div>
<div class="layui-form-item">
......@@ -135,19 +141,25 @@
<div class="layui-form-item">
<label class="layui-form-label">中文介绍</label>
<div class="layui-input-block">
<textarea class="layui-textarea" name="introduce[]"><?= $model->introduce['zh-CN'] ?></textarea>
<textarea class="layui-textarea" name="introduce[zh-CN]"><?= $model->introduce['zh-CN'] ?></textarea>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">英文介绍</label>
<div class="layui-input-block">
<textarea class="layui-textarea" name="introduce[]"><?= $model->introduce['en-US'] ?></textarea>
<textarea class="layui-textarea" name="introduce[en-US]"><?= $model->introduce['en-US'] ?></textarea>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">日文介绍</label>
<div class="layui-input-block">
<textarea class="layui-textarea" name="introduce[]"><?= $model->introduce['ja'] ?></textarea>
<textarea class="layui-textarea" name="introduce[ja]"><?= $model->introduce['ja'] ?></textarea>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">韩文介绍</label>
<div class="layui-input-block">
<textarea class="layui-textarea" name="introduce[ko]"><?= $model->introduce['ko'] ?></textarea>
</div>
</div>
<div class="layui-inline">
......
......@@ -34,19 +34,25 @@
<div class="layui-inline">
<label class="layui-form-label">中文名</label>
<div class="layui-input-block" style="width: 250px">
<input class="layui-input" name="nickname[]" value="<?= $model->nickname['zh-CN'] ?>">
<input class="layui-input" name="nickname[zh-CN]" value="<?= $model->nickname['zh-CN'] ?>">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">英文名</label>
<div class="layui-input-block" style="width: 250px">
<input class="layui-input" name="nickname[]" value="<?= $model->nickname['en-US'] ?>">
<input class="layui-input" name="nickname[en-US]" value="<?= $model->nickname['en-US'] ?>">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">日文名</label>
<div class="layui-input-block" style="width: 250px">
<input class="layui-input" name="nickname[]" value="<?= $model->nickname['ja'] ?>">
<input class="layui-input" name="nickname[ja]" value="<?= $model->nickname['ja'] ?>">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">韩文名</label>
<div class="layui-input-block" style="width: 250px">
<input class="layui-input" name="nickname[ko]" value="<?= $model->nickname['ko'] ?>">
</div>
</div>
<div class="layui-form-item">
......@@ -141,19 +147,25 @@
<div class="layui-form-item">
<label class="layui-form-label">中文介绍</label>
<div class="layui-input-block">
<textarea class="layui-textarea" name="introduce[]"><?= $model->introduce['zh-CN'] ?></textarea>
<textarea class="layui-textarea" name="introduce[zh-CN]"><?= $model->introduce['zh-CN'] ?></textarea>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">英文介绍</label>
<div class="layui-input-block">
<textarea class="layui-textarea" name="introduce[]"><?= $model->introduce['en-US'] ?></textarea>
<textarea class="layui-textarea" name="introduce[en-US]"><?= $model->introduce['en-US'] ?></textarea>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">日文介绍</label>
<div class="layui-input-block">
<textarea class="layui-textarea" name="introduce[]"><?= $model->introduce['ja'] ?></textarea>
<textarea class="layui-textarea" name="introduce[ja]"><?= $model->introduce['ja'] ?></textarea>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">韩文介绍</label>
<div class="layui-input-block">
<textarea class="layui-textarea" name="introduce[ko]"><?= $model->introduce['ko'] ?></textarea>
</div>
</div>
<div class="layui-inline">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment