fixed plugin column languages
This commit is contained in:
parent
4f88ce7570
commit
32dfe47037
|
|
@ -123,6 +123,7 @@ class Manager
|
|||
public function getPluginOrFail($code): ?Plugin
|
||||
{
|
||||
$plugin = $this->getPlugin($code);
|
||||
$plugin->handleLabel();
|
||||
if (empty($plugin)) {
|
||||
throw new \Exception('无效的插件');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,6 +93,24 @@ class Plugin implements Arrayable, \ArrayAccess
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* 处理插件后台设置字段多语言 优先级: label > label_key
|
||||
* 有label字段则直接返回, label_key 则翻译
|
||||
*/
|
||||
public function handleLabel()
|
||||
{
|
||||
$this->columns = collect($this->columns)->map(function ($item) {
|
||||
$labelKey = $item['label_key'] ?? '';
|
||||
$label = $item['label'] ?? '';
|
||||
if (empty($label) && $labelKey) {
|
||||
$languageKey = "{$this->dirName}::{$labelKey}";
|
||||
$item['label'] = trans($languageKey);
|
||||
}
|
||||
return $item;
|
||||
})->toArray();
|
||||
}
|
||||
|
||||
|
||||
public function getDirname(): string
|
||||
{
|
||||
return $this->dirName;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@
|
|||
*/
|
||||
|
||||
return [
|
||||
'publishable_key' => 'Publishable Key',
|
||||
|
||||
'title_info' => 'Card information',
|
||||
'cardnum' => 'Cardnum',
|
||||
'expiration_date' => 'Expiration Date',
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@
|
|||
*/
|
||||
|
||||
return [
|
||||
'publishable_key' => '公钥',
|
||||
|
||||
'title_info' => '卡信息',
|
||||
'cardnum' => '卡号',
|
||||
'expiration_date' => '截止日期',
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
return [
|
||||
[
|
||||
'name' => 'publishable_key',
|
||||
'label' => '公钥',
|
||||
'label_key' => 'common.publishable_key',
|
||||
'type' => 'string',
|
||||
'required' => true,
|
||||
'rules' => 'required|size:32',
|
||||
|
|
|
|||
Loading…
Reference in New Issue