Skip to content

Commit a4618d5

Browse files
Copilottyped-sigtermautofix-ci[bot]
authored
refactor: 重构 i18n (#68)
Co-authored-by: Typed SIGTERM <[email protected]> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent 212419f commit a4618d5

38 files changed

+801
-623
lines changed

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,4 @@ coverage
3131
components.d.ts
3232
.env
3333

34-
.vscode/**
35-
!.vscode/extensions.json
36-
3734
src-tauri/gen

.tool-versions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
bun 1.2.14
1+
bun 1.2.22

.vscode/extensions.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"tauri-apps.tauri-vscode",
66
"dbaeumer.vscode-eslint",
77
"antfu.unocss",
8-
"huacnlee.autocorrect"
8+
"huacnlee.autocorrect",
9+
"lokalise.i18n-ally"
910
]
1011
}

.vscode/settings.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"typescript.tsdk": "node_modules/typescript/lib",
3+
"i18n-ally.localesPaths": [
4+
"src/locales"
5+
],
6+
"cSpell.words": [
7+
"namelist"
8+
]
9+
}

bun.lock

Lines changed: 230 additions & 73 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
"@typed-sigterm/eslint-config": "^1.6.0",
3333
"@types/bun": "^1.2.22",
3434
"@types/markdown-it": "^14.1.2",
35-
"@types/mixpanel-browser": "^2.66.0",
3635
"@types/semver": "^7.7.1",
3736
"@vitejs/plugin-vue": "^6.0.1",
3837
"@vitejs/plugin-vue-jsx": "^5.1.1",
@@ -44,20 +43,22 @@
4443
"js-confetti": "^0.13.1",
4544
"markdown-it-for-inline": "^2.0.1",
4645
"mitt": "^3.0.1",
47-
"mixpanel-browser": "^2.70.0",
46+
"mixpanel-browser": "^2.71.0",
4847
"mock-local-storage": "^1.1.24",
4948
"naive-ui": "^2.43.1",
49+
"npm-run-all2": "^8.0.4",
5050
"pinia": "^3.0.3",
5151
"postcss-preset-env": "^10.3.1",
5252
"semver": "^7.7.2",
5353
"unocss": "^66.5.1",
5454
"unplugin-icons": "^22.3.0",
5555
"unplugin-vue-components": "^29.0.0",
5656
"unplugin-vue-markdown": "^29.1.0",
57+
"vite": "^7.1.9",
5758
"vitest": "^3.2.4",
5859
"vue": "^3.5.21",
5960
"vue-i18n": "^11.1.12",
60-
"vue-tsc": "3.0.7",
61+
"vue-tsc": "^3.1.0",
6162
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz",
6263
"zod": "^4.1.8"
6364
},
@@ -66,8 +67,5 @@
6667
"core-js",
6768
"esbuild",
6869
"vue-demi"
69-
],
70-
"patchedDependencies": {
71-
"@tauri-apps/[email protected]": "patches/@tauri-apps%[email protected]"
72-
}
70+
]
7371
}

patches/@tauri-apps%[email protected]

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/app.vue

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
<script lang="tsx" setup>
22
import { promiseTimeout, useScreenOrientation, watchImmediate } from '@vueuse/core';
3-
import mp from 'mixpanel-browser';
43
import { enUS, zhCN } from 'naive-ui';
54
import { computed, markRaw, onMounted, ref, watch } from 'vue';
65
import { useI18n } from 'vue-i18n';
76
import { useThemeStore } from '@/stores/theme';
8-
import { __APP__, __GA__, isPortable } from '@/utils/app';
7+
import { __APP__, isPortable } from '@/utils/app';
98
import { bus } from '@/utils/event';
109
import { initPortable } from '@/utils/fs';
1110
import { triggerWelcomeGuide } from '@/utils/guide';
1211
import { setupI18nHooks, ui } from '@/utils/ui';
12+
import { initAnalytics } from './utils/analytics';
1313
1414
setupI18nHooks();
1515
1616
const i18n = useI18n();
17-
const { t } = useI18n({ useScope: 'local' });
17+
const { t } = i18n;
1818
watchImmediate(i18n.locale, (v) => {
1919
document.documentElement.lang = v;
2020
});
@@ -49,14 +49,14 @@ function alertOrientation() {
4949
5050
return new Promise<void>((resolve) => {
5151
const modal = ui.dialog.info({
52-
title: t('orientation.title'),
52+
title: t('app.orientation.title'),
5353
content: () => (
5454
<>
55-
<p class="m-0">{t('orientation.content-1')}</p>
56-
<p class="mt-1">{t('orientation.content-2')}</p>
55+
<p class="m-0">{t('app.orientation.content-1')}</p>
56+
<p class="mt-1">{t('app.orientation.content-2')}</p>
5757
</>
5858
),
59-
positiveText: i18n.t('confirm'),
59+
positiveText: t('confirm'),
6060
closable: false,
6161
onPositiveClick: () => closedOrientation = true, // 手动关闭,下次不再弹窗
6262
onAfterLeave: resolve,
@@ -77,14 +77,6 @@ watch(orientation, () => {
7777
alertOrientation();
7878
});
7979
80-
const token = import.meta.env.EXC_MIXPANEL_TOKEN;
81-
mp.init(token, {
82-
persistence: 'localStorage',
83-
track_pageview: __GA__,
84-
});
85-
if (!__GA__)
86-
mp.disable();
87-
8880
// portable 下 localStorage 与文件同步
8981
onMounted(async () => {
9082
if (__APP__ && await isPortable()) // tree-shake
@@ -94,6 +86,8 @@ onMounted(async () => {
9486
function hideSpin() {
9587
document.getElementById('app')!.removeAttribute('data-loading');
9688
}
89+
90+
onMounted(initAnalytics);
9791
</script>
9892

9993
<template>
@@ -120,17 +114,3 @@ function hideSpin() {
120114
transition: opacity 0.3s;
121115
}
122116
</style>
123-
124-
<i18n lang="yaml">
125-
en:
126-
orientation:
127-
title: Prefer Landscape Mode
128-
content-1: ExCaller is designed to be used in landscape mode, and may have UI issues in portrait mode.
129-
content-2: You can open the notification bar and enable "Auto-rotate", then rotate your device to landscape mode.
130-
131-
zh-CN:
132-
orientation:
133-
title: 推荐横屏使用
134-
content-1: ExCaller 被设计为横屏使用,竖屏使用可能出现问题。
135-
content-2: 您可以下拉通知栏打开“自动旋转”,并将设备旋转至横屏模式。
136-
</i18n>

src/components/changelog.vue

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useI18n } from 'vue-i18n';
44
import { __CANARY__, getBuildMeta, GITHUB_REPO_URL } from '@/utils/app';
55
import ChangelogMd from '../../CHANGELOG.md';
66
7-
const { t } = useI18n({ useScope: 'local' });
7+
const { t } = useI18n();
88
const meta = getBuildMeta();
99
1010
const canaryLink = computed(() => {
@@ -24,21 +24,11 @@ const canaryLink = computed(() => {
2424

2525
<br>
2626

27-
{{ t('build-time') }}
27+
{{ t('changelog.build-time') }}
2828
<NTime :time="meta.buildTime" />
2929
</NAlert>
3030

3131
<ChangelogWrapper>
3232
<ChangelogMd />
3333
</ChangelogWrapper>
3434
</template>
35-
36-
<i18n lang="yaml">
37-
en:
38-
canary-tip: For the latest changes in the canary version, please visit {0}.
39-
build-time: "Build time:"
40-
41-
zh-CN:
42-
canary-tip: Canary 版本更新内容请前往 {0} 查看。
43-
build-time: 构建时间:
44-
</i18n>

src/components/checksum.vue

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const { value } = defineProps<{
88
describes: string
99
}>();
1010
11-
const { t } = useI18n({ useScope: 'local' });
11+
const { t } = useI18n();
1212
const { copy, copied, isSupported } = useClipboard();
1313
1414
const expanded = ref(false);
@@ -25,7 +25,7 @@ const [DefineOperations, Operations] = createReusableTemplate();
2525
<template #trigger>
2626
<ILucideCircleHelp :size="20" />
2727
</template>
28-
{{ t('notes', [describes]) }}
28+
{{ t('checksum.notes', [describes]) }}
2929
</NTooltip>
3030

3131
<NTooltip v-if="isSupported">
@@ -40,34 +40,20 @@ const [DefineOperations, Operations] = createReusableTemplate();
4040
<template #trigger>
4141
<ILucideMinus :size="20" @click="expanded = false" />
4242
</template>
43-
{{ t('collapse') }}
43+
{{ t('checksum.collapse') }}
4444
</NTooltip>
4545
<NTooltip v-else>
4646
<template #trigger>
4747
<ILucidePlus :size="20" @click="expanded = true" />
4848
</template>
49-
{{ t('expand') }}
49+
{{ t('checksum.expand') }}
5050
</NTooltip>
5151
</DefineOperations>
5252

5353
<p v-if="value" class="flex flex-wrap items-center gap-1">
54-
<span v-text="t('label')" />
54+
<span v-text="t('checksum.label')" />
5555
<Operations v-if="expanded" />
5656
<span class="border-1 font-mono break-anywhere mr-1" v-text="shown" />
5757
<Operations v-if="!expanded" />
5858
</p>
5959
</template>
60-
61-
<i18n lang="yaml">
62-
en:
63-
label: 'Checksum:'
64-
notes: Used to verify the integrity of {0}. If {0} is modified, the entire checksum will change
65-
expand: Expand
66-
collapse: Collapse
67-
68-
zh-CN:
69-
label: 校验码:
70-
notes: 用于验证{0}完整性,若{0}被修改,整串校验码会改变
71-
expand: 展开
72-
collapse: 收起
73-
</i18n>

0 commit comments

Comments
 (0)