From d253c6461317c7692a37f53a105488c466bbf0e9 Mon Sep 17 00:00:00 2001 From: Edward Yang Date: Thu, 11 Aug 2022 15:37:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=8F=92=E4=BB=B6=E9=80=89?= =?UTF-8?q?=E9=A1=B9=E5=A4=9A=E8=AF=AD=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- beike/Plugin/Plugin.php | 26 +++++++++++++++++++++----- plugins/Paypal/Lang/en/setting.php | 15 +++++++++++++++ plugins/Paypal/Lang/zh_cn/setting.php | 15 +++++++++++++++ plugins/Paypal/columns.php | 4 ++-- 4 files changed, 53 insertions(+), 7 deletions(-) create mode 100644 plugins/Paypal/Lang/en/setting.php create mode 100644 plugins/Paypal/Lang/zh_cn/setting.php 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,