diff --git a/beike/Plugin/Plugin.php b/beike/Plugin/Plugin.php index a9ce0710..ea1bcfbf 100644 --- a/beike/Plugin/Plugin.php +++ b/beike/Plugin/Plugin.php @@ -100,16 +100,32 @@ class Plugin implements Arrayable, \ArrayAccess 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); + $item = $this->transLabel($item); + if (isset($item['options'])) { + $item['options'] = collect($item['options'])->map(function ($option) { + return $this->transLabel($option); + })->toArray(); } return $item; })->toArray(); } + /** + * 翻译 label + * @param $item + * @return mixed + */ + private function transLabel($item) + { + $labelKey = $item['label_key'] ?? ''; + $label = $item['label'] ?? ''; + if (empty($label) && $labelKey) { + $languageKey = "{$this->dirName}::{$labelKey}"; + $item['label'] = trans($languageKey); + } + return $item; + } + public function getDirname(): string { diff --git a/plugins/Paypal/Lang/en/setting.php b/plugins/Paypal/Lang/en/setting.php new file mode 100644 index 00000000..f969effa --- /dev/null +++ b/plugins/Paypal/Lang/en/setting.php @@ -0,0 +1,15 @@ + + * @created 2022-08-11 15:26:18 + * @modified 2022-08-11 15:26:18 + */ + +return [ + 'sandbox_mode' => 'Sandbox Mode', + 'enabled' => 'Enabled', +]; diff --git a/plugins/Paypal/Lang/zh_cn/setting.php b/plugins/Paypal/Lang/zh_cn/setting.php new file mode 100644 index 00000000..785809a8 --- /dev/null +++ b/plugins/Paypal/Lang/zh_cn/setting.php @@ -0,0 +1,15 @@ + + * @created 2022-08-11 15:26:18 + * @modified 2022-08-11 15:26:18 + */ + +return [ + 'sandbox_mode' => '沙盒模式', + 'enabled' => '开启', +]; diff --git a/plugins/Paypal/columns.php b/plugins/Paypal/columns.php index bd7188ab..12888ef4 100644 --- a/plugins/Paypal/columns.php +++ b/plugins/Paypal/columns.php @@ -44,10 +44,10 @@ return [ ], [ 'name' => 'sandbox_mode', - 'label' => '沙盒模式', + 'label_key' => 'setting.sandbox_mode', 'type' => 'select', 'options' => [ - ['value' => '1', 'label' => '开启'], + ['value' => '1', 'label_key' => 'setting.enabled'], ['value' => '0', 'label' => '关闭'] ], 'required' => true,