Skip to content

Commit 94f02c1

Browse files
author
sheepzh
committed
Support Germany
1 parent 4f9877a commit 94f02c1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+677
-199
lines changed

script/crowdin/common.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export const ALL_TRANS_LOCALES: timer.Locale[] = [
1414
'pt_PT',
1515
'uk',
1616
'es',
17+
'de',
1718
]
1819

1920
const CROWDIN_I18N_MAP: Record<CrowdinLanguage, timer.Locale> = {
@@ -24,6 +25,7 @@ const CROWDIN_I18N_MAP: Record<CrowdinLanguage, timer.Locale> = {
2425
'pt-PT': 'pt_PT',
2526
uk: 'uk',
2627
'es-ES': 'es',
28+
de: 'de',
2729
}
2830

2931
const I18N_CROWDIN_MAP: Record<timer.Locale, CrowdinLanguage> = {
@@ -34,6 +36,7 @@ const I18N_CROWDIN_MAP: Record<timer.Locale, CrowdinLanguage> = {
3436
pt_PT: 'pt-PT',
3537
uk: 'uk',
3638
es: 'es-ES',
39+
de: 'de',
3740
}
3841

3942
export const crowdinLangOf = (locale: timer.Locale) => I18N_CROWDIN_MAP[locale]

script/crowdin/crowdin.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,5 @@ type CrowdinLanguage =
3939
| 'ja'
4040
| 'pt-PT'
4141
| 'uk'
42-
| 'es-ES'
42+
| 'es-ES'
43+
| 'de'

src/app/Layout/Menu.tsx

Lines changed: 36 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66
*/
77

88
import type { Ref } from "vue"
9-
import type { IconProps, MenuItemRegistered } from "element-plus"
9+
import type { IconProps } from "element-plus"
1010
import type { Router } from "vue-router"
1111
import type { I18nKey } from "@app/locale"
12-
import type { MenuMessage } from "@i18n/message/app/menu"
1312

1413
import { defineComponent, h, onMounted, ref, watch } from "vue"
1514
import { ElIcon, ElMenu, ElMenuItem, ElMenuItemGroup } from "element-plus"
@@ -27,83 +26,83 @@ import { createTabAfterCurrent } from "@api/chrome/tab"
2726
import { ANALYSIS_ROUTE, MERGE_ROUTE } from "@app/router/constants"
2827

2928
type _MenuItem = {
30-
title: keyof MenuMessage
29+
title: I18nKey
3130
icon: IconProps | string
3231
route?: string
3332
href?: string
3433
index?: string
3534
}
3635

3736
type _MenuGroup = {
38-
title: keyof MenuMessage
37+
title: I18nKey
3938
children: _MenuItem[]
4039
}
4140

4241
/**
4342
* Menu items
4443
*/
4544
const MENUS: _MenuGroup[] = [{
46-
title: 'data',
45+
title: msg => msg.menu.data,
4746
children: [{
48-
title: 'dashboard',
47+
title: msg => msg.menu.dashboard,
4948
route: '/data/dashboard',
5049
icon: Stopwatch
5150
}, {
52-
title: 'dataReport',
51+
title: msg => msg.menu.dataReport,
5352
route: '/data/report',
5453
icon: Table
5554
}, {
56-
title: 'siteAnalysis',
55+
title: msg => msg.menu.siteAnalysis,
5756
route: ANALYSIS_ROUTE,
5857
icon: Trend
5958
}, {
60-
title: 'dataClear',
59+
title: msg => msg.menu.dataClear,
6160
route: '/data/manage',
6261
icon: Database
6362
}]
6463
}, {
65-
title: 'behavior',
64+
title: msg => msg.menu.behavior,
6665
children: [{
67-
title: 'habit',
66+
title: msg => msg.menu.habit,
6867
route: '/behavior/habit',
6968
icon: Aim
7069
}, {
71-
title: 'limit',
70+
title: msg => msg.menu.limit,
7271
route: '/behavior/limit',
7372
icon: Timer
7473
}]
7574
}, {
76-
title: 'additional',
75+
title: msg => msg.menu.additional,
7776
children: [{
78-
title: 'siteManage',
77+
title: msg => msg.menu.siteManage,
7978
route: '/additional/site-manage',
8079
icon: Website
8180
}, {
82-
title: 'whitelist',
81+
title: msg => msg.menu.whitelist,
8382
route: '/additional/whitelist',
8483
icon: Whitelist
8584
}, {
86-
title: 'mergeRule',
85+
title: msg => msg.menu.mergeRule,
8786
route: MERGE_ROUTE,
8887
icon: Rank
8988
}, {
90-
title: 'option',
89+
title: msg => msg.menu.option,
9190
route: '/additional/option',
9291
icon: SetUp
9392
}]
9493
}, {
95-
title: 'other',
94+
title: msg => msg.menu.other,
9695
children: [{
97-
title: 'userManual',
96+
title: msg => msg.base.guidePage,
9897
href: getGuidePageUrl(),
9998
icon: Memo,
10099
index: '_guide',
101100
}, {
102-
title: 'helpUs',
101+
title: msg => msg.menu.helpUs,
103102
route: '/other/help',
104103
icon: HelpFilled,
105104
}, {
106-
title: "about",
105+
title: msg => msg.menu.about,
107106
route: '/other/about',
108107
icon: About,
109108
}]
@@ -122,7 +121,7 @@ const openHref = (href: string) => createTabAfterCurrent(href)
122121
function handleClick(menuItem: _MenuItem, router: Router, currentActive: Ref<string>) {
123122
const { route, title, href } = menuItem
124123
if (route) {
125-
openMenu(route, msg => msg.menu[title], router)
124+
openMenu(route, title, router)
126125
} else {
127126
openHref(href)
128127
currentActive.value = router.currentRoute?.value?.path
@@ -138,32 +137,25 @@ const iconStyle: Partial<CSSStyleDeclaration> = {
138137

139138
function renderMenuLeaf(menu: _MenuItem, router: Router, currentActive: Ref<string>) {
140139
const { route, title, icon, index } = menu
141-
const props: { onClick: (item: MenuItemRegistered) => void; index?: string } = {
142-
onClick: (_item) => handleClick(menu, router, currentActive)
143-
}
144-
const realIndex = index || route
145-
realIndex && (props.index = realIndex)
146-
return h(ElMenuItem, props, {
147-
default: () => (
148-
<ElIcon size={15} style={iconStyle}>
149-
{h(icon)}
150-
</ElIcon>)
151-
,
152-
title: () => h('span', t(msg => msg.menu[title])),
153-
})
154-
}
155-
156-
function renderMenu(menu: _MenuGroup, router: Router, currentActive: Ref<string>) {
157-
const title = t(msg => msg.menu[menu.title])
158-
return h(ElMenuItemGroup, { title }, () => menu.children.map(item => renderMenuLeaf(item, router, currentActive)))
140+
return <ElMenuItem
141+
onClick={(_item) => handleClick(menu, router, currentActive)}
142+
index={index || route}
143+
v-slots={{
144+
default: () => (
145+
<ElIcon size={15} style={iconStyle}>
146+
{h(icon)}
147+
</ElIcon>),
148+
title: () => <span>{t(title)}</span>
149+
}}
150+
/>
159151
}
160152

161153
async function initTitle(router: Router) {
162154
await router.isReady()
163155
const currentPath = router.currentRoute.value.path
164156
for (const group of MENUS) {
165157
for (const { route, title } of group.children) {
166-
const docTitle = route === currentPath && t(msg => msg.menu[title])
158+
const docTitle = route === currentPath && t(title)
167159
if (docTitle) {
168160
document.title = docTitle
169161
return
@@ -186,7 +178,9 @@ const _default = defineComponent(() => {
186178
return () => (
187179
<div class="menu-container">
188180
<ElMenu defaultActive={currentActive.value}>
189-
{MENUS.map(menu => renderMenu(menu, router, currentActive))}
181+
{MENUS.map(menu => <ElMenuItemGroup title={t(menu.title)}>
182+
{menu.children.map(item => renderMenuLeaf(item, router, currentActive))}
183+
</ElMenuItemGroup>)}
190184
</ElMenu>
191185
</div>
192186
)

src/app/components/DataManage/ClearPanel/ClearFilter/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const _default = defineComponent({
6161
size="small"
6262
onClick={() => ctx.emit("delete")}
6363
>
64-
{t(msg => msg.item.operation.delete)}
64+
{t(msg => msg.button.delete)}
6565
</ElButton>
6666
</div>
6767
</div>

src/app/components/Limit/LimitTable/column/LimitOperationColumn.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ const LOCALE_WIDTH: { [locale in timer.Locale]: number } = {
5656
pt_PT: 250,
5757
uk: 260,
5858
es: 240,
59+
de: 250,
5960
}
6061

6162
const _default = defineComponent({

src/app/components/Report/ReportTable/columns/OperationColumn.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const LOCALE_WIDTH: { [locale in timer.Locale]: number } = {
5050
pt_PT: 340,
5151
uk: 400,
5252
es: 360,
53+
de: 370,
5354
}
5455
const _default = defineComponent({
5556
emits: {

src/app/components/Report/ReportTable/columns/OperationDeleteButton.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ import { formatTime } from "@util/time"
1414
import { cvt2LocaleTime } from "@app/util/time"
1515
import { useReportFilter } from "../../context"
1616

17-
const deleteButtonText = t(msg => msg.item.operation.delete)
18-
1917
/**
2018
* Compute the confirm text for one item
2119
*
@@ -64,7 +62,7 @@ const _default = defineComponent({
6462
return () => <PopupConfirmButton
6563
buttonIcon={Delete}
6664
buttonType="danger"
67-
buttonText={deleteButtonText}
65+
buttonText={t(msg => msg.button.delete)}
6866
confirmText={deleteMsg.value}
6967
visible={props.visible}
7068
onConfirm={() => ctx.emit("confirm")}

src/app/components/Report/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ async function handleBatchDelete(tableInstance: TableInstance, filterOption: Rep
104104
ElMessageBox({
105105
message: await computeBatchDeleteMsg(selected, filterOption.mergeDate, filterOption.dateRange),
106106
type: "warning",
107-
confirmButtonText: t(msg => msg.confirm.confirmMsg),
107+
confirmButtonText: t(msg => msg.button.okey),
108108
showCancelButton: true,
109-
cancelButtonText: t(msg => msg.confirm.cancelMsg),
109+
cancelButtonText: t(msg => msg.button.dont),
110110
// Cant close this on press ESC
111111
closeOnPressEscape: false,
112112
// Cant close this on clicking modal

src/app/components/SiteManage/SiteManageFilter.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import { t } from "@app/locale"
1515
const hostPlaceholder = t(msg => msg.siteManage.hostPlaceholder)
1616
const aliasPlaceholder = t(msg => msg.siteManage.aliasPlaceholder)
1717
const onlyDetectedLabel = t(msg => msg.siteManage.onlyDetected)
18-
const addButtonText = t(msg => msg.siteManage.button.add)
1918

2019
const _default = defineComponent({
2120
props: {
@@ -49,7 +48,7 @@ const _default = defineComponent({
4948
onChange={val => onlyDetected.value = val}
5049
/>
5150
<ButtonFilterItem
52-
text={addButtonText}
51+
text={t(msg => msg.button.create)}
5352
icon={<Plus />}
5453
type="success"
5554
onClick={() => ctx.emit("create")}

src/app/components/SiteManage/SiteManageModify/index.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ async function handleAdd(siteInfo: timer.site.SiteInfo): Promise<boolean> {
6868
return !existed
6969
}
7070

71-
const BTN_ADD_TXT = t(msg => msg.siteManage.button.add)
72-
7371
function initData(): _FormData {
7472
return {
7573
key: undefined,
@@ -113,7 +111,7 @@ const _default = defineComponent({
113111

114112
return () => <ElDialog
115113
width={450}
116-
title={BTN_ADD_TXT}
114+
title={t(msg => msg.button.create)}
117115
modelValue={visible.value}
118116
closeOnClickModal={false}
119117
onClose={() => visible.value = false}
@@ -123,7 +121,7 @@ const _default = defineComponent({
123121
<SiteManageAliasFormItem modelValue={formData.alias} onInput={val => formData.alias = val} onEnter={save} />
124122
</ElForm>,
125123
footer: () => <ElButton type="primary" icon={<Check />} onClick={save}>
126-
{t(msg => msg.siteManage.button.save)}
124+
{t(msg => msg.button.save)}
127125
</ElButton>,
128126
}}
129127
/>

0 commit comments

Comments
 (0)