fixed admin languages

This commit is contained in:
Edward Yang 2022-08-04 15:34:11 +08:00
parent f14ef5a029
commit 3b1eaca6fb
4 changed files with 57 additions and 1 deletions

View File

@ -31,5 +31,33 @@ class ShareViewData
View::share('languages', LanguageRepo::enabled());
View::share('shop_base_url', shop_route('home.index'));
View::share('categories', hook_filter('header.categories', CategoryRepo::getTwoLevelCategories()));
if (is_admin()) {
View::share('admin_languages', $this->handleAdminLanguages());
}
}
/**
* 处理后台语言包列表
*
* @return array
*/
private function handleAdminLanguages(): array
{
$items = [];
$languages = admin_languages();
foreach ($languages as $language) {
$path = lang_path("{$language}/admin/base.php");
if (file_exists($path)) {
$baseData = require_once($path);
}
$name = $baseData['name'] ?? '';
$items[] = [
'code' => $language,
'name' => $name,
];
}
return $items;
}
}

View File

@ -11,10 +11,10 @@
namespace Beike\Services;
use Illuminate\Support\Str;
use Beike\Repositories\BrandRepo;
use Beike\Repositories\ProductRepo;
use Beike\Shop\Http\Resources\BrandDetail;
use Illuminate\Support\Str;
class DesignService
{

View File

@ -0,0 +1,14 @@
<?php
/**
* base.php
*
* @copyright 2022 opencart.cn - All Rights Reserved
* @link http://www.guangdawangluo.com
* @author Edward Yang <yangjin@opencart.cn>
* @created 2022-08-04 15:29:49
* @modified 2022-08-04 15:29:49
*/
return [
'name' => 'English',
];

View File

@ -0,0 +1,14 @@
<?php
/**
* base.php
*
* @copyright 2022 opencart.cn - All Rights Reserved
* @link http://www.guangdawangluo.com
* @author Edward Yang <yangjin@opencart.cn>
* @created 2022-08-04 15:29:49
* @modified 2022-08-04 15:29:49
*/
return [
'name' => '简体中文',
];