feat: 应用增加英文翻译

This commit is contained in:
zhengkunwang223 2023-02-17 16:21:13 +08:00 committed by zhengkunwang223
parent d47559e410
commit 5ef011b619
11 changed files with 27 additions and 14 deletions

View file

@ -4,6 +4,9 @@ GOCLEAN=$(GOCMD) clean
GOARCH=amd64 GOARCH=amd64
GOOS=linux GOOS=linux
GOARCH=$(shell go env GOARCH)
GOOS=$(shell go env GOOS )
BASE_PAH := $(shell pwd) BASE_PAH := $(shell pwd)
BUILD_PATH = $(BASE_PAH)/build BUILD_PATH = $(BASE_PAH)/build
WEB_PATH=$(BASE_PAH)/frontend WEB_PATH=$(BASE_PAH)/frontend

View file

@ -42,7 +42,8 @@ type AppDefine struct {
Name string `json:"name"` Name string `json:"name"`
Tags []string `json:"tags"` Tags []string `json:"tags"`
Versions []string `json:"versions"` Versions []string `json:"versions"`
ShortDesc string `json:"shortDesc"` ShortDescZh string `json:"shortDescZh"`
ShortDescEn string `json:"shortDescEn"`
Type string `json:"type"` Type string `json:"type"`
Required []string `json:"Required"` Required []string `json:"Required"`
CrossVersionUpdate bool `json:"crossVersionUpdate"` CrossVersionUpdate bool `json:"crossVersionUpdate"`

View file

@ -4,7 +4,8 @@ type App struct {
BaseModel BaseModel
Name string `json:"name" gorm:"type:varchar(64);not null"` Name string `json:"name" gorm:"type:varchar(64);not null"`
Key string `json:"key" gorm:"type:varchar(64);not null;uniqueIndex"` Key string `json:"key" gorm:"type:varchar(64);not null;uniqueIndex"`
ShortDesc string `json:"shortDesc" gorm:"type:longtext;"` ShortDescZh string `json:"shortDescZh" gorm:"type:longtext;"`
ShortDescEn string `json:"shortDescEn" gorm:"type:longtext;"`
Icon string `json:"icon" gorm:"type:longtext;"` Icon string `json:"icon" gorm:"type:longtext;"`
Type string `json:"type" gorm:"type:varchar(64);not null"` Type string `json:"type" gorm:"type:varchar(64);not null"`
Status string `json:"status" gorm:"type:varchar(64);not null"` Status string `json:"status" gorm:"type:varchar(64);not null"`

View file

@ -359,12 +359,12 @@ func (a AppService) GetAppUpdate() (*response.AppUpdateRes, error) {
return nil, err return nil, err
} }
res.Version = list.Version res.Version = list.Version
if common.CompareVersion(list.Version, setting.AppStoreVersion) { if setting.AppStoreVersion == "" || common.CompareVersion(list.Version, setting.AppStoreVersion) {
res.CanUpdate = true res.CanUpdate = true
res.DownloadPath = fmt.Sprintf("%s/%s/%s/appstore/apps-%s.tar.gz", global.CONF.System.RepoUrl, global.CONF.System.Mode, setting.SystemVersion, list.Version) res.DownloadPath = fmt.Sprintf("%s/%s/%s/appstore/apps-%s.tar.gz", global.CONF.System.RepoUrl, global.CONF.System.Mode, setting.SystemVersion, list.Version)
return res, err return res, err
} }
return nil, err return res, nil
} }
func (a AppService) SyncAppList() error { func (a AppService) SyncAppList() error {

View file

@ -474,7 +474,8 @@ func getApps(oldApps []model.App, items []dto.AppDefine) map[string]model.App {
app.Name = item.Name app.Name = item.Name
app.Limit = item.Limit app.Limit = item.Limit
app.Key = item.Key app.Key = item.Key
app.ShortDesc = item.ShortDesc app.ShortDescZh = item.ShortDescZh
app.ShortDescEn = item.ShortDescEn
app.Website = item.Website app.Website = item.Website
app.Document = item.Document app.Document = item.Document
app.Github = item.Github app.Github = item.Github

View file

@ -3,7 +3,6 @@ package business
import ( import (
"github.com/1Panel-dev/1Panel/backend/app/service" "github.com/1Panel-dev/1Panel/backend/app/service"
"github.com/1Panel-dev/1Panel/backend/global" "github.com/1Panel-dev/1Panel/backend/global"
"github.com/1Panel-dev/1Panel/backend/utils/common"
) )
func Init() { func Init() {
@ -11,7 +10,7 @@ func Init() {
if err != nil { if err != nil {
global.LOG.Errorf("sync app error: %s", err.Error()) global.LOG.Errorf("sync app error: %s", err.Error())
} }
if common.CompareVersion(setting.AppStoreVersion, "0.0") { if setting.AppStoreVersion != "" {
return return
} }
if err := service.NewIAppService().SyncAppList(); err != nil { if err := service.NewIAppService().SyncAppList(); err != nil {

View file

@ -6,6 +6,7 @@ import (
"github.com/1Panel-dev/1Panel/cmd/server/cmd" "github.com/1Panel-dev/1Panel/cmd/server/cmd"
_ "github.com/1Panel-dev/1Panel/cmd/server/docs" _ "github.com/1Panel-dev/1Panel/cmd/server/docs"
_ "net/http/pprof"
) )
// @title 1Panel // @title 1Panel

View file

@ -6,7 +6,8 @@ export namespace App {
icon: string; icon: string;
key: string; key: string;
tags: Tag[]; tags: Tag[];
shortDesc: string; shortDescZh: string;
shortDescEn: string;
author: string; author: string;
source: string; source: string;
type: string; type: string;

View file

@ -20,7 +20,7 @@
:type="activeTag === item.key ? 'primary' : ''" :type="activeTag === item.key ? 'primary' : ''"
:plain="activeTag !== item.key" :plain="activeTag !== item.key"
> >
{{ item.name }} {{ language == 'zh' ? item.name : item.key }}
</el-button> </el-button>
</div> </div>
</el-col> </el-col>
@ -71,12 +71,12 @@
</div> </div>
<div class="app-desc"> <div class="app-desc">
<span class="desc"> <span class="desc">
{{ app.shortDesc }} {{ language == 'zh' ? app.shortDescZh : app.shortDescEn }}
</span> </span>
</div> </div>
<div class="app-tag"> <div class="app-tag">
<el-tag v-for="(tag, ind) in app.tags" :key="ind" :colr="getColor(ind)"> <el-tag v-for="(tag, ind) in app.tags" :key="ind" :colr="getColor(ind)">
{{ tag.name }} {{ language == 'zh' ? tag.name : tag.key }}
</el-tag> </el-tag>
</div> </div>
<div class="divider"></div> <div class="divider"></div>
@ -100,6 +100,9 @@ import i18n from '@/lang';
import Detail from '../detail/index.vue'; import Detail from '../detail/index.vue';
import router from '@/routers'; import router from '@/routers';
import { MsgSuccess } from '@/utils/message'; import { MsgSuccess } from '@/utils/message';
import { useI18n } from 'vue-i18n';
const language = useI18n().locale.value;
let req = reactive({ let req = reactive({
name: '', name: '',

View file

@ -15,7 +15,7 @@
</div> </div>
<div class="description"> <div class="description">
<span> <span>
{{ app.shortDesc }} {{ language == 'zh' ? app.shortDescZh : app.shortDescEn }}
</span> </span>
</div> </div>
<div class="version"> <div class="version">
@ -94,10 +94,11 @@
import { GetApp, GetAppDetail } from '@/api/modules/app'; import { GetApp, GetAppDetail } from '@/api/modules/app';
import LayoutContent from '@/layout/layout-content.vue'; import LayoutContent from '@/layout/layout-content.vue';
import { onMounted, ref } from 'vue'; import { onMounted, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import Install from './install/index.vue'; import Install from './install/index.vue';
const language = useI18n().locale.value;
interface OperateProps { interface OperateProps {
// id: number;
appKey: string; appKey: string;
} }

View file

@ -15,7 +15,7 @@
</div> </div>
<div class="h-app-desc"> <div class="h-app-desc">
<span> <span>
{{ app.shortDesc }} {{ language == 'zh' ? app.shortDescZh : app.shortDescEn }}
</span> </span>
</div> </div>
</div> </div>
@ -43,8 +43,10 @@ import { App } from '@/api/interface/app';
import { Dashboard } from '@/api/interface/dashboard'; import { Dashboard } from '@/api/interface/dashboard';
import { SearchApp } from '@/api/modules/app'; import { SearchApp } from '@/api/modules/app';
import { reactive, ref } from 'vue'; import { reactive, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
const router = useRouter(); const router = useRouter();
const language = useI18n().locale.value;
let req = reactive({ let req = reactive({
name: '', name: '',