修复后台插件显示多语言问题
This commit is contained in:
parent
0307831081
commit
30f7e5d2a2
|
|
@ -16,15 +16,10 @@ class PluginResource extends JsonResource
|
|||
*/
|
||||
public function toArray($request): array
|
||||
{
|
||||
$currentLocale = locale();
|
||||
|
||||
$name = is_array($this->name) ? ($this->name[$currentLocale] ?? '') : (string) $this->name;
|
||||
$description = is_array($this->description) ? ($this->description[$currentLocale] ?? '') : (string) $this->description;
|
||||
|
||||
$data = [
|
||||
return [
|
||||
'code' => $this->code,
|
||||
'name' => $name,
|
||||
'description' => $description,
|
||||
'name' => $this->getLocaleName(),
|
||||
'description' => $this->getLocaleDescription(),
|
||||
'path' => $this->path,
|
||||
'version' => $this->version,
|
||||
'dir_name' => $this->dirName,
|
||||
|
|
@ -36,7 +31,5 @@ class PluginResource extends JsonResource
|
|||
'installed' => $this->getInstalled(),
|
||||
'edit_url' => $this->getEditUrl(),
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -154,9 +154,17 @@ class Plugin implements Arrayable, \ArrayAccess
|
|||
|
||||
public function getLocaleName(): string
|
||||
{
|
||||
$currentLocale = locale();
|
||||
$currentLocale = admin_locale();
|
||||
|
||||
return is_array($this->name) ? ($this->name[$currentLocale] ?? '') : (string) $this->name;
|
||||
if (is_array($this->name)) {
|
||||
if ($this->name[$currentLocale] ?? '') {
|
||||
return $this->name[$currentLocale];
|
||||
}
|
||||
|
||||
return array_values($this->name)[0];
|
||||
}
|
||||
|
||||
return (string) $this->name;
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
|
|
@ -166,9 +174,17 @@ class Plugin implements Arrayable, \ArrayAccess
|
|||
|
||||
public function getLocaleDescription(): string
|
||||
{
|
||||
$currentLocale = locale();
|
||||
$currentLocale = admin_locale();
|
||||
|
||||
return is_array($this->description) ? ($this->description[$currentLocale] ?? '') : (string) $this->description;
|
||||
if (is_array($this->description)) {
|
||||
if ($this->description[$currentLocale] ?? '') {
|
||||
return $this->description[$currentLocale];
|
||||
}
|
||||
|
||||
return array_values($this->description)[0];
|
||||
}
|
||||
|
||||
return (string) $this->description;
|
||||
}
|
||||
|
||||
public function getDirname(): string
|
||||
|
|
|
|||
Loading…
Reference in New Issue